Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
0a06753dac29
Commit
577565d9
authored
Oct 15, 2015
by
Stan Hu
Browse files
Add system notes for restored branches
parent
bd7a3232aecf
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/repository.rb
View file @
0a06753d
...
...
@@ -480,6 +480,10 @@ def merged_to_root_ref?(branch_name)
end
end
def
merge_base
(
first_commit_id
,
second_commit_id
)
rugged
.
merge_base
(
first_commit_id
,
second_commit_id
)
end
def
search_files
(
query
,
ref
)
offset
=
2
args
=
%W(git grep -i -n --before-context
#{
offset
}
--after-context
#{
offset
}
#{
query
}
#{
ref
||
root_ref
}
)
...
...
app/services/merge_requests/refresh_service.rb
View file @
0a06753d
...
...
@@ -10,13 +10,12 @@ def execute(oldrev, newrev, ref)
# Leave a system note if a branch were deleted/added
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
||
Gitlab
::
Git
.
blank_ref?
(
newrev
)
presence
=
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
?
:add
:
:delete
comment_mr_
branch_presence_changed
(
presen
ce
)
comment_mr_branch_presence_changed
comment_mr_
with_commits
if
@commits
.
presen
t?
else
@commits
=
@project
.
repository
.
commits_between
(
oldrev
,
newrev
)
close_merge_requests
comment_mr_with_commits
close_merge_requests
end
reload_merge_requests
...
...
@@ -79,8 +78,29 @@ def reload_merge_requests
end
# Add comment about branches being deleted or added to merge requests
def
comment_mr_branch_presence_changed
(
presence
)
def
comment_mr_branch_presence_changed
presence
=
Gitlab
::
Git
.
blank_ref?
(
@oldrev
)
?
:add
:
:delete
merge_requests_for_source_branch
.
each
do
|
merge_request
|
last_commit
=
merge_request
.
last_commit
# Only look at changed commits in restore branch case
unless
Gitlab
::
Git
.
blank_ref?
(
@newrev
)
begin
# Since any number of commits could have been made to the restored branch,
# find the common root to see what has been added.
common_ref
=
@project
.
repository
.
merge_base
(
last_commit
.
id
,
@newrev
)
# If the last_commit no longer exists in this new branch,
# gitlab_git throws a Rugged::OdbError
# This is fixed in https://gitlab.com/gitlab-org/gitlab_git/merge_requests/52
@commits
=
@project
.
repository
.
commits_between
(
common_ref
,
@newrev
)
if
common_ref
rescue
=>
e
end
# Prevent system notes from seeing a blank SHA
@oldrev
=
nil
end
SystemNoteService
.
change_branch_presence
(
merge_request
,
merge_request
.
project
,
@current_user
,
:source
,
@branch_name
,
presence
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment