Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
501ce37f
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
501ce37f
编写于
7月 18, 2016
作者:
V
Valery Sizov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
上级
a27212ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
59 deletion
+43
-59
CHANGELOG
CHANGELOG
+2
-0
app/models/repository.rb
app/models/repository.rb
+28
-44
app/services/create_branch_service.rb
app/services/create_branch_service.rb
+13
-15
未找到文件。
CHANGELOG
浏览文件 @
501ce37f
Please view this file on the master branch, on stable branches it's out of date.
v 8.11.0 (unreleased)
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
v 8.10.0 (unreleased)
- Fix profile activity heatmap to show correct day name (eanplatter)
...
...
app/models/repository.rb
浏览文件 @
501ce37f
...
...
@@ -704,6 +704,7 @@ class Repository
options
[
:commit
]
=
{
message:
message
,
branch:
ref
,
update_ref:
false
,
}
raw_repository
.
mkdir
(
path
,
options
)
...
...
@@ -719,6 +720,7 @@ class Repository
options
[
:commit
]
=
{
message:
message
,
branch:
ref
,
update_ref:
false
,
}
options
[
:file
]
=
{
...
...
@@ -739,7 +741,8 @@ class Repository
options
[
:author
]
=
committer
options
[
:commit
]
=
{
message:
message
,
branch:
ref
branch:
ref
,
update_ref:
false
,
}
options
[
:file
]
=
{
...
...
@@ -779,11 +782,10 @@ class Repository
merge_index
=
rugged
.
merge_commits
(
our_commit
,
their_commit
)
return
false
if
merge_index
.
conflicts?
commit_with_hooks
(
user
,
merge_request
.
target_branch
)
do
|
tmp_ref
|
commit_with_hooks
(
user
,
merge_request
.
target_branch
)
do
actual_options
=
options
.
merge
(
parents:
[
our_commit
,
their_commit
],
tree:
merge_index
.
write_tree
(
rugged
),
update_ref:
tmp_ref
)
commit_id
=
Rugged
::
Commit
.
create
(
rugged
,
actual_options
)
...
...
@@ -798,15 +800,14 @@ class Repository
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
...
...
@@ -816,7 +817,7 @@ class Repository
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
,
...
...
@@ -827,8 +828,7 @@ class Repository
},
committer:
committer
,
tree:
cherry_pick_tree_id
,
parents:
[
rugged
.
lookup
(
source_sha
)],
update_ref:
ref
)
parents:
[
rugged
.
lookup
(
source_sha
)])
end
end
...
...
@@ -929,20 +929,6 @@ class Repository
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
...
...
@@ -955,33 +941,31 @@ class Repository
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'
)
end
unless
newrev
raise
CommitError
.
new
(
'Failed to create commit'
)
end
GitHooksService
.
new
.
execute
(
current_user
,
path_to_repo
,
oldrev
,
newrev
,
ref
)
do
if
was_empty
||
!
target_branch
# Create branch
rugged
.
references
.
create
(
ref
,
newrev
)
else
# Update head
current_head
=
find_branch
(
branch
).
target
GitHooksService
.
new
.
execute
(
current_user
,
path_to_repo
,
oldrev
,
newrev
,
ref
)
do
if
was_empty
||
!
target_branch
# Create branch
rugged
.
references
.
create
(
ref
,
newrev
)
# Make sure target branch was not changed during pre-receive hook
if
current_head
==
oldrev
rugged
.
references
.
update
(
ref
,
newrev
)
else
# Update head
current_head
=
find_branch
(
branch
).
target
# Make sure target branch was not changed during pre-receive hook
if
current_head
==
oldrev
rugged
.
references
.
update
(
ref
,
newrev
)
else
raise
CommitError
.
new
(
'Commit was rejected because branch received new push'
)
end
raise
CommitError
.
new
(
'Commit was rejected because branch received new push'
)
end
end
newrev
end
newrev
end
def
ls_files
(
ref
)
...
...
app/services/create_branch_service.rb
浏览文件 @
501ce37f
...
...
@@ -15,21 +15,19 @@ class CreateBranchService < BaseService
return
error
(
'Branch already exists'
)
end
new_branch
=
nil
if
source_project
!=
@project
repository
.
with_tmp_ref
do
|
tmp_ref
|
repository
.
fetch_ref
(
source_project
.
repository
.
path_to_repo
,
"refs/heads/
#{
ref
}
"
,
tmp_ref
)
new_branch
=
repository
.
add_branch
(
current_user
,
branch_name
,
tmp_ref
)
end
else
new_branch
=
repository
.
add_branch
(
current_user
,
branch_name
,
ref
)
end
new_branch
=
if
source_project
!=
@project
repository
.
fetch_ref
(
source_project
.
repository
.
path_to_repo
,
"refs/heads/
#{
ref
}
"
,
"refs/heads/
#{
branch_name
}
"
)
repository
.
after_create_branch
repository
.
find_branch
(
branch_name
)
else
repository
.
add_branch
(
current_user
,
branch_name
,
ref
)
end
if
new_branch
success
(
new_branch
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录