Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6f3501fe
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,发现更多精彩内容 >>
提交
6f3501fe
编写于
8月 01, 2016
作者:
S
Sean McGivern
提交者:
Fatih Acet
8月 12, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix match line headers at start / end of file
上级
f3cf40b8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
16 deletion
+33
-16
lib/gitlab/conflict/file.rb
lib/gitlab/conflict/file.rb
+33
-16
未找到文件。
lib/gitlab/conflict/file.rb
浏览文件 @
6f3501fe
...
...
@@ -77,6 +77,10 @@ module Gitlab
def
sections
return
@sections
if
@sections
candidate_match_headers
=
lines
.
map
do
|
line
|
"
#{
line
.
text
}
"
if
line
.
text
.
match
(
/\A[A-Za-z$_]/
)
&&
line
.
type
.
nil?
end
chunked_lines
=
lines
.
chunk
{
|
line
|
line
.
type
.
nil?
}
last_candidate_match_header
=
nil
match_line_header
=
nil
...
...
@@ -85,40 +89,41 @@ module Gitlab
@sections
=
chunked_lines
.
flat_map
.
with_index
do
|
(
no_conflict
,
lines
),
i
|
section
=
nil
lines
.
each
do
|
line
|
last_candidate_match_header
=
"
#{
line
.
text
}
"
if
line
.
text
.
match
(
/\A[A-Za-z$_]/
)
end
if
no_conflict
conflict_before
=
i
>
0
conflict_after
=
chunked_lines
.
peek
if
conflict_before
&&
conflict_after
if
lines
.
length
>
CONTEXT_LINES
*
2
head_lines
=
lines
.
first
(
CONTEXT_LINES
)
tail_lines
=
lines
.
last
(
CONTEXT_LINES
)
first_tail_line
=
tail_lines
.
first
match_line_header
=
last_candidate_match_header
match_line
=
Gitlab
::
Diff
::
Line
.
new
(
''
,
'match'
,
first_tail_line
.
index
,
first_tail_line
.
old_pos
,
first_tail_line
.
new_pos
)
update_match_line_text
(
match_line
,
head_lines
.
last
,
candidate_match_headers
)
match_line
=
create_match_line
(
tail_lines
.
first
)
update_match_line_text
(
match_line
,
tail_lines
.
last
,
candidate_match_headers
)
section
=
[
{
conflict:
false
,
lines:
lines
.
first
(
CONTEXT_LINES
)
},
{
conflict:
false
,
lines:
head_lines
},
{
conflict:
false
,
lines:
tail_lines
.
unshift
(
match_line
)
}
]
end
elsif
conflict_after
lines
=
lines
.
last
(
CONTEXT_LINES
)
tail_lines
=
lines
.
last
(
CONTEXT_LINES
)
if
lines
.
length
>
CONTEXT_LINES
match_line
=
create_match_line
(
tail_lines
.
first
)
tail_lines
.
unshift
(
match_line
)
end
lines
=
tail_lines
elsif
conflict_before
lines
=
lines
.
first
(
CONTEXT_LINES
)
end
end
if
match_line
&&
!
section
match_line
.
text
=
"@@ -
#{
match_line
.
old_pos
}
,
#{
lines
.
last
.
old_pos
}
+
#{
match_line
.
new_pos
}
,
#{
lines
.
last
.
new_pos
}
@@
#{
match_line_header
}
"
end
update_match_line_text
(
match_line
,
lines
.
last
,
candidate_match_headers
)
unless
section
section
||=
{
conflict:
!
no_conflict
,
lines:
lines
}
section
[
:id
]
=
line_code
(
lines
.
first
)
unless
no_conflict
...
...
@@ -130,6 +135,18 @@ module Gitlab
Gitlab
::
Diff
::
LineCode
.
generate
(
our_path
,
line
.
new_pos
,
line
.
old_pos
)
end
def
create_match_line
(
line
)
Gitlab
::
Diff
::
Line
.
new
(
''
,
'match'
,
line
.
index
,
line
.
old_pos
,
line
.
new_pos
)
end
def
update_match_line_text
(
match_line
,
line
,
headers
)
return
unless
match_line
header
=
headers
.
first
(
line
.
index
).
compact
.
last
match_line
.
text
=
"@@ -
#{
match_line
.
old_pos
}
,
#{
line
.
old_pos
}
+
#{
match_line
.
new_pos
}
,
#{
line
.
new_pos
}
@@
#{
header
}
"
end
def
as_json
(
opts
=
nil
)
{
old_path:
their_path
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录