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
Tatuya Kamada
gitlab-ce
Commits
2ea5b37f
Commit
2ea5b37f
authored
Feb 10, 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 and refactors for code related to forks.
parent
11345866
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
app/helpers/commits_helper.rb
app/helpers/commits_helper.rb
+2
-0
app/models/repository.rb
app/models/repository.rb
+0
-2
app/services/commits/revert_service.rb
app/services/commits/revert_service.rb
+25
-4
No files found.
app/helpers/commits_helper.rb
View file @
2ea5b37f
...
@@ -124,6 +124,8 @@ module CommitsHelper
...
@@ -124,6 +124,8 @@ module CommitsHelper
end
end
def
revert_commit_link
(
show_modal_condition
,
continue_to_path
)
def
revert_commit_link
(
show_modal_condition
,
continue_to_path
)
return
unless
current_user
if
show_modal_condition
if
show_modal_condition
link_to
(
'Revert'
,
'#modal-revert-commit'
,
link_to
(
'Revert'
,
'#modal-revert-commit'
,
'data-target'
=>
'#modal-revert-commit'
,
'data-target'
=>
'#modal-revert-commit'
,
...
...
app/models/repository.rb
View file @
2ea5b37f
...
@@ -628,8 +628,6 @@ class Repository
...
@@ -628,8 +628,6 @@ class Repository
args
=
[
commit
.
id
,
source_sha
]
args
=
[
commit
.
id
,
source_sha
]
args
<<
{
mainline:
1
}
if
commit
.
merge_commit?
args
<<
{
mainline:
1
}
if
commit
.
merge_commit?
# Temporary branch exists and contains the revert commit
return
true
if
(
base_branch
!=
target_branch
)
&&
find_branch
(
target_branch
)
return
false
unless
diff_exists?
(
source_sha
,
commit
.
id
)
return
false
unless
diff_exists?
(
source_sha
,
commit
.
id
)
revert_index
=
rugged
.
revert_commit
(
*
args
)
revert_index
=
rugged
.
revert_commit
(
*
args
)
...
...
app/services/commits/revert_service.rb
View file @
2ea5b37f
...
@@ -14,9 +14,7 @@ module Commits
...
@@ -14,9 +14,7 @@ module Commits
if
commit
if
commit
success
success
else
else
error
(
"Sorry, we cannot revert this
#{
params
[
:revert_type_title
]
}
automatically.
custom_error
It may have already been reverted, or a more recent commit may
have updated some of its content."
)
end
end
rescue
Repository
::
CommitError
,
Gitlab
::
Git
::
Repository
::
InvalidBlobName
,
GitHooksService
::
PreReceiveError
,
ValidationError
=>
ex
rescue
Repository
::
CommitError
,
Gitlab
::
Git
::
Repository
::
InvalidBlobName
,
GitHooksService
::
PreReceiveError
,
ValidationError
=>
ex
error
(
ex
.
message
)
error
(
ex
.
message
)
...
@@ -24,7 +22,11 @@ module Commits
...
@@ -24,7 +22,11 @@ module Commits
def
commit
def
commit
if
@create_merge_request
if
@create_merge_request
repository
.
revert
(
current_user
,
@commit
,
@target_branch
,
@commit
.
revert_branch_name
)
# Temporary branch exists and contains the revert commit
return
true
if
repository
.
find_branch
(
@commit
.
revert_branch_name
)
return
false
unless
create_target_branch
repository
.
revert
(
current_user
,
@commit
,
@commit
.
revert_branch_name
)
else
else
repository
.
revert
(
current_user
,
@commit
,
@target_branch
)
repository
.
revert
(
current_user
,
@commit
,
@target_branch
)
end
end
...
@@ -32,6 +34,25 @@ module Commits
...
@@ -32,6 +34,25 @@ module Commits
private
private
def
custom_error
if
@branch_error_msg
error
(
"There was an error creating the source branch:
#{
@branch_error_msg
}
"
)
else
error
(
"Sorry, we cannot revert this
#{
params
[
:revert_type_title
]
}
automatically.
It may have already been reverted, or a more recent commit may
have updated some of its content."
)
end
end
def
create_target_branch
result
=
CreateBranchService
.
new
(
@project
,
current_user
)
.
execute
(
@commit
.
revert_branch_name
,
@target_branch
,
source_project:
@source_project
)
@branch_error_msg
=
result
[
:message
]
result
[
:status
]
!=
:error
end
def
raise_error
(
message
)
def
raise_error
(
message
)
raise
ValidationError
.
new
(
message
)
raise
ValidationError
.
new
(
message
)
end
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