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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d7878c3f
Commit
d7878c3f
authored
Mar 31, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix other cases where git hooks fail due to old commits
parent
6b3b0711
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+2
-4
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+12
-0
No files found.
lib/gitlab/git_access.rb
View file @
d7878c3f
...
...
@@ -202,13 +202,11 @@ module Gitlab
return
build_status_object
(
true
)
end
blank_oldrev
=
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
# if oldrev is blank, the branch was just created
oldrev
=
project
.
default_branch
if
blank_oldrev
oldrev
=
project
.
default_branch
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
commits
(
newrev
,
oldrev
,
project
).
each
do
|
commit
|
next
if
commit_from_annex_sync?
(
commit
.
safe_message
)
||
(
blank_oldrev
&&
old_commit?
(
commit
)
)
next
if
commit_from_annex_sync?
(
commit
.
safe_message
)
||
old_commit?
(
commit
)
if
status_object
=
check_commit
(
commit
,
git_hook
)
return
status_object
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
d7878c3f
...
...
@@ -391,6 +391,18 @@ describe Gitlab::GitAccess, lib: true do
# push to new branch, so use a blank old rev and new ref
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/new-branch'
,
Gitlab
::
Git
::
BLANK_SHA
,
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)).
to
be_allowed
end
it
'allows githook for any change with an old bad commit'
do
bad_commit
=
double
(
"Commit"
,
safe_message:
'Some change'
).
as_null_object
allow
(
bad_commit
).
to
receive
(
:refs
).
and_return
([
'heads/master'
])
allow_any_instance_of
(
Repository
).
to
receive
(
:commits_between
).
and_return
([
bad_commit
])
project
.
create_git_hook
project
.
git_hook
.
update
(
commit_message_regex:
"Change some files"
)
# push to new branch, so use a blank old rev and new ref
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
,
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)).
to
be_allowed
end
end
describe
"member_check"
do
...
...
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