diff options
author | Sean McGivern <sean@gitlab.com> | 2017-09-28 13:11:10 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-09-28 13:11:10 +0300 |
commit | b63e8d64c1a2d39a7e18f22b526e48bab2c79956 (patch) | |
tree | d83eb0d2fba53327b2ebbb3a6e5e1663ad30551a /lib/gitlab/git/repository.rb | |
parent | e03bad12bf579a83a814c07399ef9bdc37e2f120 (diff) |
Handle error when fetching ref for MR with deleted source branch
If the ref doesn't exist, and the source branch is deleted, we can't get it back
easily. Previously, we ignored this error by shelling out, so replicate that
behaviour.
Diffstat (limited to 'lib/gitlab/git/repository.rb')
-rw-r--r-- | lib/gitlab/git/repository.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 8c1df650567..6baff362dad 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -947,7 +947,11 @@ module Gitlab if start_repository == self yield commit(start_branch_name) else - sha = start_repository.commit(start_branch_name).sha + start_commit = start_repository.commit(start_branch_name) + + return yield nil unless start_commit + + sha = start_commit.sha if branch_commit = commit(sha) yield branch_commit @@ -976,8 +980,9 @@ module Gitlab with_repo_branch_commit(source_repository, source_branch) do |commit| if commit write_ref(local_ref, commit.sha) + true else - raise Rugged::ReferenceError, 'source repository is empty' + false end end end |