Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0f08bb86
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 搜索 >>
提交
0f08bb86
编写于
9月 07, 2016
作者:
J
Jacob Vosmaer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename {commit,update_branch}_with_hooks
上级
a7502691
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
17 deletion
+17
-17
app/models/repository.rb
app/models/repository.rb
+9
-9
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+8
-8
未找到文件。
app/models/repository.rb
浏览文件 @
0f08bb86
...
...
@@ -757,7 +757,7 @@ class Repository
end
def
commit_dir
(
user
,
path
,
message
,
branch
)
commit
_with_hooks
(
user
,
branch
)
do
|
ref
|
update_branch
_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
options
=
{}
options
[
:committer
]
=
committer
...
...
@@ -774,7 +774,7 @@ class Repository
end
def
commit_file
(
user
,
path
,
content
,
message
,
branch
,
update
)
commit
_with_hooks
(
user
,
branch
)
do
|
ref
|
update_branch
_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
options
=
{}
options
[
:committer
]
=
committer
...
...
@@ -796,7 +796,7 @@ class Repository
end
def
update_file
(
user
,
path
,
content
,
branch
:,
previous_path
:,
message
:)
commit
_with_hooks
(
user
,
branch
)
do
|
ref
|
update_branch
_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
options
=
{}
options
[
:committer
]
=
committer
...
...
@@ -823,7 +823,7 @@ class Repository
end
def
remove_file
(
user
,
path
,
message
,
branch
)
commit
_with_hooks
(
user
,
branch
)
do
|
ref
|
update_branch
_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
options
=
{}
options
[
:committer
]
=
committer
...
...
@@ -871,7 +871,7 @@ 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
update_branch
_with_hooks
(
user
,
merge_request
.
target_branch
)
do
actual_options
=
options
.
merge
(
parents:
[
our_commit
,
their_commit
],
tree:
merge_index
.
write_tree
(
rugged
),
...
...
@@ -889,7 +889,7 @@ class Repository
return
false
unless
revert_tree_id
commit
_with_hooks
(
user
,
base_branch
)
do
update_branch
_with_hooks
(
user
,
base_branch
)
do
committer
=
user_to_committer
(
user
)
source_sha
=
Rugged
::
Commit
.
create
(
rugged
,
message:
commit
.
revert_message
,
...
...
@@ -906,7 +906,7 @@ class Repository
return
false
unless
cherry_pick_tree_id
commit
_with_hooks
(
user
,
base_branch
)
do
update_branch
_with_hooks
(
user
,
base_branch
)
do
committer
=
user_to_committer
(
user
)
source_sha
=
Rugged
::
Commit
.
create
(
rugged
,
message:
commit
.
message
,
...
...
@@ -922,7 +922,7 @@ class Repository
end
def
resolve_conflicts
(
user
,
branch
,
params
)
commit
_with_hooks
(
user
,
branch
)
do
update_branch
_with_hooks
(
user
,
branch
)
do
committer
=
user_to_committer
(
user
)
Rugged
::
Commit
.
create
(
rugged
,
params
.
merge
(
author:
committer
,
committer:
committer
))
...
...
@@ -1026,7 +1026,7 @@ class Repository
Gitlab
::
Popen
.
popen
(
args
,
path_to_repo
)
end
def
commit
_with_hooks
(
current_user
,
branch
)
def
update_branch
_with_hooks
(
current_user
,
branch
)
update_autocrlf_option
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
branch
...
...
spec/models/repository_spec.rb
浏览文件 @
0f08bb86
...
...
@@ -441,7 +441,7 @@ describe Repository, models: true do
end
end
describe
'#
commit
_with_hooks'
do
describe
'#
update_branch
_with_hooks'
do
let
(
:old_rev
)
{
'0b4bc9a49b562e85de7cc9e834518ea6828729b9'
}
# git rev-parse feature
let
(
:new_rev
)
{
'a74ae73c1ccde9b974a70e82b901588071dc142a'
}
# commit whose parent is old_rev
...
...
@@ -454,20 +454,20 @@ describe Repository, models: true do
it
'runs without errors'
do
expect
do
repository
.
commit
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
repository
.
update_branch
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
end
.
not_to
raise_error
end
it
'ensures the autocrlf Git option is set to :input'
do
expect
(
repository
).
to
receive
(
:update_autocrlf_option
)
repository
.
commit
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
repository
.
update_branch
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
end
context
"when the branch wasn't empty"
do
it
'updates the head'
do
expect
(
repository
.
find_branch
(
'feature'
).
target
.
id
).
to
eq
(
old_rev
)
repository
.
commit
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
repository
.
update_branch
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
expect
(
repository
.
find_branch
(
'feature'
).
target
.
id
).
to
eq
(
new_rev
)
end
end
...
...
@@ -479,7 +479,7 @@ describe Repository, models: true do
branch
=
'feature-ff-target'
repository
.
add_branch
(
user
,
branch
,
old_rev
)
expect
{
repository
.
commit
_with_hooks
(
user
,
branch
)
{
new_rev
}
}.
not_to
raise_error
expect
{
repository
.
update_branch
_with_hooks
(
user
,
branch
)
{
new_rev
}
}.
not_to
raise_error
end
end
...
...
@@ -488,7 +488,7 @@ describe Repository, models: true do
# We use the fact that 'master' has diverged from 'feature' (new_rev):
# updating 'master' to new_rev would make us lose commits, which should
# not happen.
expect
{
repository
.
commit
_with_hooks
(
user
,
'master'
)
{
new_rev
}
}.
to
raise_error
(
Repository
::
CommitError
)
expect
{
repository
.
update_branch
_with_hooks
(
user
,
'master'
)
{
new_rev
}
}.
to
raise_error
(
Repository
::
CommitError
)
end
end
...
...
@@ -497,7 +497,7 @@ describe Repository, models: true do
allow_any_instance_of
(
Gitlab
::
Git
::
Hook
).
to
receive
(
:trigger
).
and_return
([
false
,
''
])
expect
do
repository
.
commit
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
repository
.
update_branch
_with_hooks
(
user
,
'feature'
)
{
new_rev
}
end
.
to
raise_error
(
GitHooksService
::
PreReceiveError
)
end
end
...
...
@@ -516,7 +516,7 @@ describe Repository, models: true do
expect
(
repository
).
to
receive
(
:expire_has_visible_content_cache
)
expect
(
repository
).
to
receive
(
:expire_branch_count_cache
)
repository
.
commit
_with_hooks
(
user
,
'new-feature'
)
{
new_rev
}
repository
.
update_branch
_with_hooks
(
user
,
'new-feature'
)
{
new_rev
}
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录