Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
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 @@ class Project < ActiveRecord::Base
...
@@ -1378,6 +1378,7 @@ class Project < ActiveRecord::Base
repository
.
raw_repository
.
write_ref
(
'HEAD'
,
"refs/heads/
#{
branch
}
"
)
repository
.
raw_repository
.
write_ref
(
'HEAD'
,
"refs/heads/
#{
branch
}
"
)
repository
.
copy_gitattributes
(
branch
)
repository
.
copy_gitattributes
(
branch
)
repository
.
after_change_head
repository
.
after_change_head
ProjectCacheWorker
.
perform_async
(
self
.
id
,
[],
[
:commit_count
])
reload_default_branch
reload_default_branch
else
else
errors
.
add
(
:base
,
"Could not change HEAD: branch '
#{
branch
}
' does not exist"
)
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 @@ class ProjectCacheWorker
...
@@ -27,6 +27,7 @@ class ProjectCacheWorker
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
update_statistics
(
project
,
statistics
=
[])
def
update_statistics
(
project
,
statistics
=
[])
return
if
Gitlab
::
Database
.
read_only?
return
unless
try_obtain_lease_for
(
project
.
id
,
:update_statistics
)
return
unless
try_obtain_lease_for
(
project
.
id
,
:update_statistics
)
Rails
.
logger
.
info
(
"Updating statistics for project
#{
project
.
id
}
"
)
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 @@ describe Project do
...
@@ -2388,6 +2388,12 @@ describe Project do
project
.
change_head
(
project
.
default_branch
)
project
.
change_head
(
project
.
default_branch
)
end
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
it
'copies the gitattributes'
do
expect
(
project
.
repository
).
to
receive
(
:copy_gitattributes
).
with
(
project
.
default_branch
)
expect
(
project
.
repository
).
to
receive
(
:copy_gitattributes
).
with
(
project
.
default_branch
)
project
.
change_head
(
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