Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
577565d9
Commit
577565d9
authored
Oct 15, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system notes for restored branches
parent
9c67f4fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
app/models/repository.rb
app/models/repository.rb
+4
-0
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+25
-5
No files found.
app/models/repository.rb
View file @
577565d9
...
@@ -480,6 +480,10 @@ class Repository
...
@@ -480,6 +480,10 @@ class Repository
end
end
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
)
def
search_files
(
query
,
ref
)
offset
=
2
offset
=
2
args
=
%W(git grep -i -n --before-context
#{
offset
}
--after-context
#{
offset
}
#{
query
}
#{
ref
||
root_ref
}
)
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 @
577565d9
...
@@ -10,13 +10,12 @@ module MergeRequests
...
@@ -10,13 +10,12 @@ module MergeRequests
# Leave a system note if a branch were deleted/added
# Leave a system note if a branch were deleted/added
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
||
Gitlab
::
Git
.
blank_ref?
(
newrev
)
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
||
Gitlab
::
Git
.
blank_ref?
(
newrev
)
presence
=
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
?
:add
:
:delete
comment_mr_branch_presence_changed
comment_mr_
branch_presence_changed
(
presence
)
comment_mr_
with_commits
if
@commits
.
present?
else
else
@commits
=
@project
.
repository
.
commits_between
(
oldrev
,
newrev
)
@commits
=
@project
.
repository
.
commits_between
(
oldrev
,
newrev
)
close_merge_requests
comment_mr_with_commits
comment_mr_with_commits
close_merge_requests
end
end
reload_merge_requests
reload_merge_requests
...
@@ -79,8 +78,29 @@ module MergeRequests
...
@@ -79,8 +78,29 @@ module MergeRequests
end
end
# Add comment about branches being deleted or added to merge requests
# 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
|
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
(
SystemNoteService
.
change_branch_presence
(
merge_request
,
merge_request
.
project
,
@current_user
,
merge_request
,
merge_request
.
project
,
@current_user
,
:source
,
@branch_name
,
presence
)
: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