Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
657065b7
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 搜索 >>
提交
657065b7
编写于
1月 08, 2018
作者:
K
Kim "BKC" Carlbäcker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Client-prep Gitlab::Git::Repository#write_ref
上级
df744610
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
11 deletion
+19
-11
app/models/project.rb
app/models/project.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+1
-5
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+15
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-3
未找到文件。
app/models/project.rb
浏览文件 @
657065b7
...
...
@@ -1149,7 +1149,7 @@ class Project < ActiveRecord::Base
def
change_head
(
branch
)
if
repository
.
branch_exists?
(
branch
)
repository
.
before_change_head
repository
.
write_ref
(
'HEAD'
,
"refs/heads/
#{
branch
}
"
)
repository
.
raw_repository
.
write_ref
(
'HEAD'
,
"refs/heads/
#{
branch
}
"
,
shell:
false
)
repository
.
copy_gitattributes
(
branch
)
repository
.
after_change_head
reload_default_branch
...
...
app/models/repository.rb
浏览文件 @
657065b7
...
...
@@ -256,7 +256,7 @@ class Repository
# This will still fail if the file is corrupted (e.g. 0 bytes)
begin
write_ref
(
keep_around_ref_name
(
sha
),
sha
)
raw_repository
.
write_ref
(
keep_around_ref_name
(
sha
),
sha
,
shell:
false
)
rescue
Rugged
::
ReferenceError
=>
ex
Rails
.
logger
.
error
"Unable to create
#{
REF_KEEP_AROUND
}
reference for repository
#{
path
}
:
#{
ex
}
"
rescue
Rugged
::
OSError
=>
ex
...
...
@@ -270,10 +270,6 @@ class Repository
ref_exists?
(
keep_around_ref_name
(
sha
))
end
def
write_ref
(
ref_path
,
sha
)
rugged
.
references
.
create
(
ref_path
,
sha
,
force:
true
)
end
def
diverging_commit_counts
(
branch
)
root_ref_hash
=
raw_repository
.
commit
(
root_ref
).
id
cache
.
fetch
(
:"diverging_commit_counts_
#{
branch
.
name
}
"
)
do
...
...
lib/gitlab/git/repository.rb
浏览文件 @
657065b7
...
...
@@ -1103,14 +1103,27 @@ module Gitlab
end
end
def
write_ref
(
ref_path
,
ref
)
def
write_ref
(
ref_path
,
ref
,
old_ref:
nil
,
shell:
true
)
if
shell
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
else
rugged_write_ref
(
ref_path
,
ref
)
end
end
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
raise
ArgumentError
,
"invalid ref_path
#{
ref_path
.
inspect
}
"
if
ref_path
.
include?
(
' '
)
raise
ArgumentError
,
"invalid ref
#{
ref
.
inspect
}
"
if
ref
.
include?
(
"
\x00
"
)
raise
ArgumentError
,
"invalid old_ref
#{
old_ref
.
inspect
}
"
if
!
old_ref
.
nil?
&&
old_ref
.
include?
(
"
\x00
"
)
input
=
"update
#{
ref_path
}
\x00
#{
ref
}
\x00\x00
"
input
=
"update
#{
ref_path
}
\x00
#{
ref
}
\x00
#{
old_ref
}
\x00
"
run_git!
(
%w[update-ref --stdin -z]
)
{
|
stdin
|
stdin
.
write
(
input
)
}
end
def
rugged_write_ref
(
ref_path
,
ref
)
rugged
.
references
.
create
(
ref_path
,
ref
,
force:
true
)
end
def
fetch_ref
(
source_repository
,
source_ref
:,
target_ref
:)
Gitlab
::
Git
.
check_namespace!
(
source_repository
)
source_repository
=
RemoteRepository
.
new
(
source_repository
)
unless
source_repository
.
is_a?
(
RemoteRepository
)
...
...
spec/models/project_spec.rb
浏览文件 @
657065b7
...
...
@@ -1871,9 +1871,8 @@ describe Project do
end
it
'creates the new reference with rugged'
do
expect
(
project
.
repository
.
rugged
.
references
).
to
receive
(
:create
).
with
(
'HEAD'
,
"refs/heads/
#{
project
.
default_branch
}
"
,
force:
true
)
expect
(
project
.
repository
.
raw_repository
).
to
receive
(
:write_ref
).
with
(
'HEAD'
,
"refs/heads/
#{
project
.
default_branch
}
"
,
shell:
false
)
project
.
change_head
(
project
.
default_branch
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录