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
62371f69
Commit
62371f69
authored
Jun 21, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix git hooks when commit goes from web UI
parent
a7025851
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
CHANGELOG-EE
CHANGELOG-EE
+1
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+2
-1
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+18
-2
No files found.
CHANGELOG-EE
View file @
62371f69
...
...
@@ -15,6 +15,7 @@ v 8.9.0 (unreleased)
- Remove explicit Gitlab::Metrics.action assignments, are already automatic.
- [Elastic] Project members with guest role can't access confidential issues
- Ability to lock file or folder in the repository
- Fix: Git hooks don't fire when committing from the UI
v 8.8.5
- Make sure OAuth routes that we generate for Geo matches with the ones in Rails routes !444
...
...
lib/gitlab/git_access.rb
View file @
62371f69
...
...
@@ -420,7 +420,8 @@ module Gitlab
end
def
old_commit?
(
commit
)
commit
.
refs
(
project
.
repository
).
any?
# We skip refs/tmp ref because we use it for Web UI commiting
commit
.
refs
(
project
.
repository
).
reject
{
|
ref
|
ref
.
name
.
start_with?
(
'refs/tmp'
)
}.
any?
end
end
end
spec/lib/gitlab/git_access_spec.rb
View file @
62371f69
...
...
@@ -382,7 +382,8 @@ describe Gitlab::GitAccess, lib: true do
it
'allows githook for new branch 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'
])
ref_object
=
double
(
name:
'heads/master'
)
allow
(
bad_commit
).
to
receive
(
:refs
).
and_return
([
ref_object
])
allow_any_instance_of
(
Repository
).
to
receive
(
:commits_between
).
and_return
([
bad_commit
])
project
.
create_git_hook
...
...
@@ -394,7 +395,8 @@ describe Gitlab::GitAccess, lib: true do
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'
])
ref_object
=
double
(
name:
'heads/master'
)
allow
(
bad_commit
).
to
receive
(
:refs
).
and_return
([
ref_object
])
allow_any_instance_of
(
Repository
).
to
receive
(
:commits_between
).
and_return
([
bad_commit
])
project
.
create_git_hook
...
...
@@ -403,6 +405,20 @@ 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/master'
,
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
,
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)).
to
be_allowed
end
it
'does not allow any change from Web UI with bad commit'
do
bad_commit
=
double
(
"Commit"
,
safe_message:
'Some change'
).
as_null_object
# We use tmp ref a a temporary for Web UI commiting
ref_object
=
double
(
name:
'refs/tmp'
)
allow
(
bad_commit
).
to
receive
(
:refs
).
and_return
([
ref_object
])
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'
)).
not_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