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
Boxiang Sun
gitlab-ce
Commits
d9e01915
Commit
d9e01915
authored
Mar 01, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some specs for Repository#revert.
parent
0c116d8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
app/models/repository.rb
app/models/repository.rb
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+31
-4
No files found.
app/models/repository.rb
View file @
d9e01915
...
@@ -656,7 +656,7 @@ class Repository
...
@@ -656,7 +656,7 @@ class Repository
def
revert
(
user
,
commit
,
base_branch
,
revert_tree_id
=
nil
)
def
revert
(
user
,
commit
,
base_branch
,
revert_tree_id
=
nil
)
source_sha
=
find_branch
(
base_branch
).
target
source_sha
=
find_branch
(
base_branch
).
target
revert_tree_id
=
check_revert_content
(
commit
,
base_branch
)
unless
revert_tree_id
revert_tree_id
||=
check_revert_content
(
commit
,
base_branch
)
return
false
unless
revert_tree_id
return
false
unless
revert_tree_id
...
...
spec/models/repository_spec.rb
View file @
d9e01915
...
@@ -457,11 +457,38 @@ describe Repository, models: true do
...
@@ -457,11 +457,38 @@ describe Repository, models: true do
end
end
end
end
describe
'#revert
_merge
'
do
describe
'#revert'
do
it
'should revert the changes'
do
let
(
:new_image_commit
)
{
repository
.
commit
(
'33f3729a45c02fc67d00adb1b8bca394b0e761d9'
)
}
repository
.
revert
(
user
,
merge_commit
,
'master'
)
let
(
:update_image_commit
)
{
repository
.
commit
(
'2f63565e7aac07bcdadb654e253078b727143ec4'
)
}
expect
(
repository
.
blob_at_branch
(
'master'
,
'files/ruby/feature.rb'
)).
not_to
be_present
context
'when there is a conflict'
do
it
'should abort the operation'
do
expect
(
repository
.
revert
(
user
,
new_image_commit
,
'master'
)).
to
eq
(
false
)
end
end
context
'when commit was already reverted'
do
it
'should abort the operation'
do
repository
.
revert
(
user
,
update_image_commit
,
'master'
)
expect
(
repository
.
revert
(
user
,
update_image_commit
,
'master'
)).
to
eq
(
false
)
end
end
context
'when commit can be reverted'
do
it
'should revert the changes'
do
expect
(
repository
.
revert
(
user
,
update_image_commit
,
'master'
)).
to
be_truthy
end
end
context
'reverting a merge commit'
do
it
'should revert the changes'
do
merge_commit
expect
(
repository
.
blob_at_branch
(
'master'
,
'files/ruby/feature.rb'
)).
to
be_present
repository
.
revert
(
user
,
merge_commit
,
'master'
)
expect
(
repository
.
blob_at_branch
(
'master'
,
'files/ruby/feature.rb'
)).
not_to
be_present
end
end
end
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