Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3f79376c
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 搜索 >>
提交
3f79376c
编写于
1月 29, 2018
作者:
J
Jacob Vosmaer (GitLab)
提交者:
Rémy Coutable
1月 29, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set alternate object directories in run_git
上级
726c7105
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
23 deletion
+35
-23
lib/gitlab/git/blame.rb
lib/gitlab/git/blame.rb
+1
-3
lib/gitlab/git/popen.rb
lib/gitlab/git/popen.rb
+2
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+32
-20
未找到文件。
lib/gitlab/git/blame.rb
浏览文件 @
3f79376c
...
...
@@ -42,9 +42,7 @@ module Gitlab
end
def
load_blame_by_shelling_out
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
@repo
.
path
}
blame -p
#{
@sha
}
--
#{
@path
}
)
# Read in binary mode to ensure ASCII-8BIT
IO
.
popen
(
cmd
,
'rb'
)
{
|
io
|
io
.
read
}
@repo
.
shell_blame
(
@sha
,
@path
)
end
def
process_raw_blame
(
output
)
...
...
lib/gitlab/git/popen.rb
浏览文件 @
3f79376c
...
...
@@ -19,6 +19,8 @@ module Gitlab
cmd_output
=
""
cmd_status
=
0
Open3
.
popen3
(
vars
,
*
cmd
,
options
)
do
|
stdin
,
stdout
,
stderr
,
wait_thr
|
stdout
.
set_encoding
(
Encoding
::
ASCII_8BIT
)
yield
(
stdin
)
if
block_given?
stdin
.
close
...
...
lib/gitlab/git/repository.rb
浏览文件 @
3f79376c
...
...
@@ -614,11 +614,11 @@ module Gitlab
if
is_enabled
gitaly_ref_client
.
find_ref_name
(
sha
,
ref_path
)
else
args
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
for-each-ref --count=1
#{
ref_path
}
--contains
#{
sha
}
)
args
=
%W(for-each-ref --count=1
#{
ref_path
}
--contains
#{
sha
}
)
# Not found -> ["", 0]
# Found -> ["b8d95eb4969eefacb0a58f6a28f6803f8070e7b9 commit\trefs/environments/production/77\n", 0]
popen
(
args
,
@path
).
first
.
split
.
last
run_git
(
args
).
first
.
split
.
last
end
end
end
...
...
@@ -887,8 +887,7 @@ module Gitlab
"delete
#{
ref
}
\x00\x00
"
end
command
=
%W[
#{
Gitlab
.
config
.
git
.
bin_path
}
update-ref --stdin -z]
message
,
status
=
popen
(
command
,
path
)
do
|
stdin
|
message
,
status
=
run_git
(
%w[update-ref --stdin -z]
)
do
|
stdin
|
stdin
.
write
(
instructions
.
join
)
end
...
...
@@ -1409,6 +1408,11 @@ module Gitlab
end
end
def
shell_blame
(
sha
,
path
)
output
,
_status
=
run_git
(
%W(blame -p
#{
sha
}
--
#{
path
}
)
)
output
end
private
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
...
...
@@ -1433,6 +1437,12 @@ module Gitlab
def
run_git
(
args
,
chdir:
path
,
env:
{},
nice:
false
,
&
block
)
cmd
=
[
Gitlab
.
config
.
git
.
bin_path
,
*
args
]
cmd
.
unshift
(
"nice"
)
if
nice
object_directories
=
alternate_object_directories
if
object_directories
.
any?
env
[
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
]
=
object_directories
.
join
(
File
::
PATH_SEPARATOR
)
end
circuit_breaker
.
perform
do
popen
(
cmd
,
chdir
,
env
,
&
block
)
end
...
...
@@ -1624,7 +1634,7 @@ module Gitlab
offset_in_ruby
=
use_follow_flag
&&
options
[
:offset
].
present?
limit
+=
offset
if
offset_in_ruby
cmd
=
%
W[
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
log]
cmd
=
%
w[
log]
cmd
<<
"--max-count=
#{
limit
}
"
cmd
<<
'--format=%H'
cmd
<<
"--skip=
#{
offset
}
"
unless
offset_in_ruby
...
...
@@ -1640,7 +1650,7 @@ module Gitlab
cmd
+=
Array
(
options
[
:path
])
end
raw_output
=
IO
.
popen
(
cmd
)
{
|
io
|
io
.
read
}
raw_output
,
_status
=
run_git
(
cmd
)
lines
=
offset_in_ruby
?
raw_output
.
lines
.
drop
(
offset
)
:
raw_output
.
lines
lines
.
map!
{
|
c
|
Rugged
::
Commit
.
new
(
rugged
,
c
.
strip
)
}
...
...
@@ -1678,18 +1688,23 @@ module Gitlab
end
def
alternate_object_directories
relative_paths
=
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_RELATIVE_DIRECTORIES_VARIABLES
).
flatten
.
compact
relative_paths
=
relative_object_directories
if
relative_paths
.
any?
relative_paths
.
map
{
|
d
|
File
.
join
(
path
,
d
)
}
else
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
)
.
flatten
.
compact
.
flat_map
{
|
d
|
d
.
split
(
File
::
PATH_SEPARATOR
)
}
absolute_object_directories
.
flat_map
{
|
d
|
d
.
split
(
File
::
PATH_SEPARATOR
)
}
end
end
def
relative_object_directories
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_RELATIVE_DIRECTORIES_VARIABLES
).
flatten
.
compact
end
def
absolute_object_directories
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
).
flatten
.
compact
end
# Get the content of a blob for a given commit. If the blob is a commit
# (for submodules) then return the blob's OID.
def
blob_content
(
commit
,
blob_name
)
...
...
@@ -1833,13 +1848,13 @@ module Gitlab
def
count_commits_by_shelling_out
(
options
)
cmd
=
count_commits_shelling_command
(
options
)
raw_output
=
IO
.
popen
(
cmd
)
{
|
io
|
io
.
read
}
raw_output
,
_status
=
run_git
(
cmd
)
process_count_commits_raw_output
(
raw_output
,
options
)
end
def
count_commits_shelling_command
(
options
)
cmd
=
%
W[
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
rev-list]
cmd
=
%
w[
rev-list]
cmd
<<
"--after=
#{
options
[
:after
].
iso8601
}
"
if
options
[
:after
]
cmd
<<
"--before=
#{
options
[
:before
].
iso8601
}
"
if
options
[
:before
]
cmd
<<
"--max-count=
#{
options
[
:max_count
]
}
"
if
options
[
:max_count
]
...
...
@@ -1884,20 +1899,17 @@ module Gitlab
return
[]
end
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
ls-tree)
cmd
+=
%w(-r)
cmd
+=
%w(--full-tree)
cmd
+=
%w(--full-name)
cmd
+=
%W(--
#{
actual_ref
}
)
cmd
=
%W(ls-tree -r --full-tree --full-name --
#{
actual_ref
}
)
raw_output
,
_status
=
run_git
(
cmd
)
raw_output
=
IO
.
popen
(
cmd
,
&
:read
)
.
split
(
"
\n
"
).
map
do
|
f
|
lines
=
raw_output
.
split
(
"
\n
"
).
map
do
|
f
|
stuff
,
path
=
f
.
split
(
"
\t
"
)
_mode
,
type
,
_sha
=
stuff
.
split
(
" "
)
path
if
type
==
"blob"
# Contain only blob type
end
raw_output
.
compact
lines
.
compact
end
# Returns true if the given ref name exists
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录