Skip to content
Snippets Groups Projects
Commit d272eda5 authored by Valery Sizov's avatar Valery Sizov
Browse files

Fix of 'Commits being passed to custom hooks already reachable when using the UI'

parent 1c04b072
No related merge requests found
Pipeline #
Loading
Loading
@@ -97,6 +97,7 @@ v 8.10.0 (unreleased)
- Change status color and icon for running builds
- Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.`
- Fix last update timestamp on issues not preserved on gitlab.com and project imports
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
 
v 8.9.6
- Fix importing of events under notes for GitLab projects. !5154
Loading
Loading
Loading
Loading
@@ -56,7 +56,7 @@ gem 'browser', '~> 2.2'
 
# Extracting information from a git repository
# Provide access to Gitlab::Git library
gem 'gitlab_git', '~> 10.2'
gem 'gitlab_git', :git => "git@gitlab.com:gitlab-org/gitlab_git.git", branch: "optional_branch_update"
 
# LDAP Auth
# GitLab fork with several improvements to original library. For full list of changes
Loading
Loading
GIT
remote: git@gitlab.com:gitlab-org/gitlab_git.git
revision: 0df0cdd9bb1164a7595f1f69f5dfa79489e3eaf1
branch: optional_branch_update
specs:
gitlab_git (10.3.0)
activesupport (~> 4.0)
charlock_holmes (~> 0.7.3)
github-linguist (~> 4.7.0)
rugged (~> 0.24.0)
GEM
remote: https://rubygems.org/
specs:
Loading
Loading
@@ -296,11 +307,6 @@ GEM
mime-types (>= 1.16, < 3)
posix-spawn (~> 0.3)
gitlab-license (1.0.0)
gitlab_git (10.2.3)
activesupport (~> 4.0)
charlock_holmes (~> 0.7.3)
github-linguist (~> 4.7.0)
rugged (~> 0.24.0)
gitlab_meta (7.0)
gitlab_omniauth-ldap (1.2.1)
net-ldap (~> 0.9)
Loading
Loading
@@ -892,7 +898,7 @@ DEPENDENCIES
gitlab-elasticsearch-git (~> 0.0.15)
gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-license (~> 1.0)
gitlab_git (~> 10.2)
gitlab_git!
gitlab_meta (= 7.0)
gitlab_omniauth-ldap (~> 1.2.1)
gollum-lib (~> 4.1.0)
Loading
Loading
Loading
Loading
@@ -782,6 +782,7 @@ def commit_dir(user, path, message, branch)
options[:commit] = {
message: message,
branch: ref,
update_ref: false
}
 
raw_repository.mkdir(path, options)
Loading
Loading
@@ -797,6 +798,7 @@ def commit_file(user, path, content, message, branch, update)
options[:commit] = {
message: message,
branch: ref,
update_ref: false
}
 
options[:file] = {
Loading
Loading
@@ -817,7 +819,8 @@ def remove_file(user, path, message, branch)
options[:author] = committer
options[:commit] = {
message: message,
branch: ref
branch: ref,
update_ref: false
}
 
options[:file] = {
Loading
Loading
@@ -854,7 +857,7 @@ def ff_merge(user, source_sha, target_branch, options = {})
raise "Invalid merge target" if our_commit.nil?
raise "Invalid merge source" if their_commit.nil?
 
commit_with_hooks(user, target_branch) do |ref|
commit_with_hooks(user, target_branch) do
source_sha
end
end
Loading
Loading
@@ -869,11 +872,10 @@ def merge(user, source_sha, target_branch, options = {})
merge_index = rugged.merge_commits(our_commit, their_commit)
return false if merge_index.conflicts?
 
commit_with_hooks(user, target_branch) do |ref|
commit_with_hooks(user, target_branch) do
actual_options = options.merge(
parents: [our_commit, their_commit],
tree: merge_index.write_tree(rugged),
update_ref: ref
tree: merge_index.write_tree(rugged)
)
 
Rugged::Commit.create(rugged, actual_options)
Loading
Loading
@@ -886,15 +888,14 @@ def revert(user, commit, base_branch, revert_tree_id = nil)
 
return false unless revert_tree_id
 
commit_with_hooks(user, base_branch) do |ref|
commit_with_hooks(user, base_branch) do
committer = user_to_committer(user)
source_sha = Rugged::Commit.create(rugged,
message: commit.revert_message,
author: committer,
committer: committer,
tree: revert_tree_id,
parents: [rugged.lookup(source_sha)],
update_ref: ref)
parents: [rugged.lookup(source_sha)])
end
end
 
Loading
Loading
@@ -904,7 +905,7 @@ def cherry_pick(user, commit, base_branch, cherry_pick_tree_id = nil)
 
return false unless cherry_pick_tree_id
 
commit_with_hooks(user, base_branch) do |ref|
commit_with_hooks(user, base_branch) do
committer = user_to_committer(user)
source_sha = Rugged::Commit.create(rugged,
message: commit.message,
Loading
Loading
@@ -915,8 +916,7 @@ def cherry_pick(user, commit, base_branch, cherry_pick_tree_id = nil)
},
committer: committer,
tree: cherry_pick_tree_id,
parents: [rugged.lookup(source_sha)],
update_ref: ref)
parents: [rugged.lookup(source_sha)])
end
end
 
Loading
Loading
@@ -1116,20 +1116,6 @@ def fetch_ref(source_path, source_ref, target_ref)
Gitlab::Popen.popen(args, path_to_repo)
end
 
def with_tmp_ref(oldrev = nil)
random_string = SecureRandom.hex
tmp_ref = "refs/tmp/#{random_string}/head"
if oldrev && !Gitlab::Git.blank_ref?(oldrev)
rugged.references.create(tmp_ref, oldrev)
end
# Make commit in tmp ref
yield(tmp_ref)
ensure
rugged.references.delete(tmp_ref) rescue nil
end
def commit_with_hooks(current_user, branch)
update_autocrlf_option
 
Loading
Loading
@@ -1142,9 +1128,8 @@ def commit_with_hooks(current_user, branch)
oldrev = target_branch.target
end
 
with_tmp_ref(oldrev) do |tmp_ref|
# Make commit in tmp ref
newrev = yield(tmp_ref)
# Make commit
newrev = yield(ref)
 
unless newrev
raise CommitError.new('Failed to create commit')
Loading
Loading
@@ -1169,7 +1154,6 @@ def commit_with_hooks(current_user, branch)
 
newrev
end
end
 
def ls_files(ref)
actual_ref = ref || root_ref
Loading
Loading
Loading
Loading
@@ -15,20 +15,18 @@ def execute(branch_name, ref, source_project: @project)
return error('Branch already exists')
end
 
new_branch = nil
if source_project != @project
repository.with_tmp_ref do |tmp_ref|
new_branch = if source_project != @project
repository.fetch_ref(
source_project.repository.path_to_repo,
"refs/heads/#{ref}",
tmp_ref
"refs/heads/#{branch_name}"
)
 
new_branch = repository.add_branch(current_user, branch_name, tmp_ref)
end
repository.after_create_branch
repository.find_branch(branch_name)
else
new_branch = repository.add_branch(current_user, branch_name, ref)
repository.add_branch(current_user, branch_name, ref)
end
 
if new_branch
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment