Открыть боковую панель
nt_test133
nt_project_uxpg8lvcuq8w
Коммиты
c9a12b1d
Коммит
c9a12b1d
создал
Июл 06, 2016
по автору
Josh Frye
Просмотр файлов
Start of MR confict resolver service
владелец
bc7fd405
Изменения
4
Скрыть пробелы
Построчно
Рядом
app/models/merge_request.rb
Просмотр файла @
c9a12b1d
...
...
@@ -321,6 +321,18 @@ def check_if_can_be_merged
end
end
def
conflicts?
project
.
repository
.
conflicts?
(
diff_head_sha
,
target_branch
)
end
def
conflicts
project
.
repository
.
conflicts
(
diff_head_sha
,
target_branch
)
end
def
conflict_diff
(
conflict
)
project
.
repository
.
conflict_diff
(
diff_head_sha
,
target_branch
,
conflict
[
:ancestor
][:
path
])
end
def
merge_event
@merge_event
||=
target_project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
MERGED
).
last
end
...
...
app/models/repository.rb
Просмотр файла @
c9a12b1d
...
...
@@ -637,11 +637,11 @@ def tags_sorted_by(value)
def
contributors
commits
=
self
.
commits
(
nil
,
limit:
2000
,
offset:
0
,
skip_merges:
true
)
commits
.
group_by
(
&
:author_email
).
map
do
|
email
,
commits
|
commits
.
group_by
(
&
:author_email
).
map
do
|
author_email
,
author_
commits
|
contributor
=
Gitlab
::
Contributor
.
new
contributor
.
email
=
email
contributor
.
email
=
author_
email
commits
.
each
do
|
commit
|
author_
commits
.
each
do
|
commit
|
if
contributor
.
name
.
blank?
contributor
.
name
=
commit
.
author_name
end
...
...
@@ -769,6 +769,39 @@ def can_be_merged?(source_sha, target_branch)
end
end
def
conflicts?
(
source_sha
,
target_branch
)
our_commit
=
rugged
.
branches
[
target_branch
].
target
their_commit
=
rugged
.
lookup
(
source_sha
)
if
our_commit
&&
their_commit
rugged
.
merge_commits
(
our_commit
,
their_commit
).
conflicts?
else
false
end
end
def
conflicts
(
source_sha
,
target_branch
)
our_commit
=
rugged
.
branches
[
target_branch
].
target
their_commit
=
rugged
.
lookup
(
source_sha
)
if
our_commit
&&
their_commit
rugged
.
merge_commits
(
our_commit
,
their_commit
).
conflicts
else
[]
end
end
def
conflict_diff
(
source_sha
,
target_branch
,
path
)
our_commit
=
rugged
.
branches
[
target_branch
].
target
their_commit
=
rugged
.
lookup
(
source_sha
)
if
our_commit
&&
their_commit
&&
path
rugged
.
diff
(
our_commit
,
their_commit
,
{
paths:
[
path
],
context_lines:
3
})
else
[]
end
end
def
merge
(
user
,
source_sha
,
target_branch
,
options
=
{})
our_commit
=
rugged
.
branches
[
target_branch
].
target
their_commit
=
rugged
.
lookup
(
source_sha
)
...
...
app/services/merge_requests/conflicts/formatter_service.rb
0 → 100644
Просмотр файла @
c9a12b1d
module
MergeRequests
module
Conflicts
class
FormatterService
attr_accessor
:rugged_input
def
initialize
(
rugged_input
)
@rugged_input
=
rugged_input
end
def
format_from_rugged
# TODO: format!
@rugged_input
end
end
end
end
app/services/merge_requests/conflicts/resolver_service.rb
0 → 100644
Просмотр файла @
c9a12b1d
module
MergeRequests
module
Conflicts
class
ResolverService
attr_accessor
:merge_request
def
initialize
(
merge_request
)
@merge_request
=
merge_request
end
def
conflicts
return
[]
unless
@merge_request
.
conflicts?
diff_lines
=
[]
@merge_request
.
conflicts
.
each
do
|
c
|
diff_lines
.
push
(
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
@merge_request
.
conflict_diff
(
c
).
each_line
.
collect
{
|
el
|
el
.
content
}
).
to_a
)
end
diff_lines
end
end
end
end
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать