Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
projects.thm.de
GitLab
Commits
e64589a3
Commit
e64589a3
authored
Mar 22, 2019
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refresh commit count after repository head changes
parent
80fea82f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
0 deletions
+13
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/workers/project_cache_worker.rb
app/workers/project_cache_worker.rb
+1
-0
changelogs/unreleased/refresh-commit-count-after-head-change.yml
...ogs/unreleased/refresh-commit-count-after-head-change.yml
+5
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-0
No files found.
app/models/project.rb
View file @
e64589a3
...
...
@@ -1378,6 +1378,7 @@ def change_head(branch)
repository
.
raw_repository
.
write_ref
(
'HEAD'
,
"refs/heads/
#{
branch
}
"
)
repository
.
copy_gitattributes
(
branch
)
repository
.
after_change_head
ProjectCacheWorker
.
perform_async
(
self
.
id
,
[],
[
:commit_count
])
reload_default_branch
else
errors
.
add
(
:base
,
"Could not change HEAD: branch '
#{
branch
}
' does not exist"
)
...
...
app/workers/project_cache_worker.rb
View file @
e64589a3
...
...
@@ -27,6 +27,7 @@ def perform(project_id, files = [], statistics = [])
# rubocop: enable CodeReuse/ActiveRecord
def
update_statistics
(
project
,
statistics
=
[])
return
if
Gitlab
::
Database
.
read_only?
return
unless
try_obtain_lease_for
(
project
.
id
,
:update_statistics
)
Rails
.
logger
.
info
(
"Updating statistics for project
#{
project
.
id
}
"
)
...
...
changelogs/unreleased/refresh-commit-count-after-head-change.yml
0 → 100644
View file @
e64589a3
---
title
:
Refresh commit count after repository head changes
merge_request
:
26473
author
:
type
:
fixed
spec/models/project_spec.rb
View file @
e64589a3
...
...
@@ -2388,6 +2388,12 @@
project
.
change_head
(
project
.
default_branch
)
end
it
'updates commit count'
do
expect
(
ProjectCacheWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
[],
[
:commit_count
])
project
.
change_head
(
project
.
default_branch
)
end
it
'copies the gitattributes'
do
expect
(
project
.
repository
).
to
receive
(
:copy_gitattributes
).
with
(
project
.
default_branch
)
project
.
change_head
(
project
.
default_branch
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment