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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
6b0e4783
Commit
6b0e4783
authored
Feb 07, 2016
by
Rubén Dávila
Committed by
Robert Speicher
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some fixes required for conflicts on revert.
parent
91e6e32d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
app/models/repository.rb
app/models/repository.rb
+10
-7
app/services/commits/revert_service.rb
app/services/commits/revert_service.rb
+4
-2
No files found.
app/models/repository.rb
View file @
6b0e4783
...
...
@@ -628,18 +628,21 @@ class Repository
target_sha
=
find_branch
(
target_branch
).
try
(
:target
)
# First make revert in temp branch
status
=
target_sha
?
true
:
revert_commit
(
user
,
commit
,
target_branch
,
base_branch
)
rm_branch
(
target_branch
)
if
target_sha
success
=
revert_commit
(
user
,
commit
,
target_branch
,
base_branch
)
# Make the revert happen in the target branch
source_sha
=
find_branch
(
target_branch
).
target
target_sha
=
find_branch
(
base_branch
).
target
has_changes
=
is_there_something_to_merge?
(
source_sha
,
target_sha
)
if
success
&&
!
create_mr
source_sha
=
find_branch
(
target_branch
).
target
target_sha
=
find_branch
(
base_branch
).
target
has_changes
=
is_there_something_to_merge?
(
source_sha
,
target_sha
)
if
has_changes
&&
!
create_mr
status
=
revert_commit
(
user
,
commit
,
base_branch
,
base_branch
)
if
has_changes
success
=
revert_commit
(
user
,
commit
,
base_branch
,
base_branch
)
end
end
has_changes
&&
s
tatu
s
has_changes
&&
s
ucces
s
end
def
revert_commit
(
user
,
commit
,
target_branch
,
base_branch
)
...
...
app/services/commits/revert_service.rb
View file @
6b0e4783
...
...
@@ -14,7 +14,9 @@ module Commits
if
commit
success
else
error
(
"Something went wrong. Your changes were not committed"
)
error
(
"Sorry, we cannot revert this commit automatically.
It may have already been reverted, or a more recent commit may
have updated some of its content."
)
end
rescue
Repository
::
CommitError
,
Gitlab
::
Git
::
Repository
::
InvalidBlobName
,
GitHooksService
::
PreReceiveError
,
ValidationError
=>
ex
error
(
ex
.
message
)
...
...
@@ -26,7 +28,7 @@ module Commits
# Create branch with revert commit
reverted
=
repository
.
revert
(
current_user
,
@commit
,
@target_branch
,
@create_merge_request
)
unless
@create_merge_request
if
reverted
&&
!
@create_merge_request
repository
.
rm_branch
(
current_user
,
@commit
.
revert_branch_name
)
end
...
...
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