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
029fb98b
Commit
029fb98b
authored
Aug 09, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect if we didn't create the ref sooner
parent
cb308689
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
app/models/repository.rb
app/models/repository.rb
+4
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+21
-0
No files found.
app/models/repository.rb
View file @
029fb98b
...
...
@@ -999,7 +999,7 @@ class Repository
yield
(
commit
(
branch_name_or_sha
))
ensure
rugged
.
references
.
delete
(
tmp_ref
)
if
tmp_ref
rugged
.
references
.
delete
(
tmp_ref
)
if
tmp_ref
&&
ref_exists?
(
tmp_ref
)
end
def
add_remote
(
name
,
url
)
...
...
@@ -1022,6 +1022,9 @@ class Repository
def
fetch_ref
(
source_path
,
source_ref
,
target_ref
)
args
=
%W(fetch --no-tags -f
#{
source_path
}
#{
source_ref
}
:
#{
target_ref
}
)
run_git
(
args
)
# Make sure ref was created, and raise Rugged::ReferenceError when not
raise
Rugged
::
ReferenceError
unless
ref_exists?
(
target_ref
)
end
def
create_ref
(
ref
,
ref_path
)
...
...
spec/models/repository_spec.rb
View file @
029fb98b
...
...
@@ -961,6 +961,27 @@ describe Repository, models: true do
end
end
context
'when temporary ref failed to be created from other project'
do
let
(
:target_project
)
{
create
(
:project
,
:empty_repo
)
}
before
do
expect
(
target_project
.
repository
).
to
receive
(
:run_git
)
end
it
'raises Rugged::ReferenceError'
do
raise_reference_error
=
raise_error
(
Rugged
::
ReferenceError
)
do
|
err
|
expect
(
err
.
cause
).
to
be_nil
end
expect
do
GitOperationService
.
new
(
user
,
target_project
.
repository
)
.
with_branch
(
'feature'
,
start_project:
project
,
&
:itself
)
end
.
to
raise_reference_error
end
end
context
'when the update adds more than one commit'
do
let
(
:old_rev
)
{
'33f3729a45c02fc67d00adb1b8bca394b0e761d9'
}
...
...
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