diff options
author | Sean McGivern <sean@gitlab.com> | 2016-10-13 14:19:52 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-10-13 16:15:38 +0100 |
commit | 776cea4c00d883cafc2bc5381f3b61b146a93976 (patch) | |
tree | 469990cf140f9558320a5aab9c1ca46850c17a98 /app/models/deployment.rb | |
parent | a053430e94e21bbf81524304f9b52a106f654b54 (diff) | |
download | gitlab-ce-776cea4c00d883cafc2bc5381f3b61b146a93976.tar.gz |
Handle case where deployment ref no longer exists22655-deployments-don-t-always-have-keep-around-refs
Keep-around refs for deployments were only introduced in 8.10, so any
deployment created in 8.9 could have a SHA pointing to a commit that no
longer exists in the repository. We can't do anything useful with those
deployments, so make `#includes_commit?` always return false for those.
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r-- | app/models/deployment.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 82b27b78229..f63cc179b9e 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -40,7 +40,14 @@ class Deployment < ActiveRecord::Base def includes_commit?(commit) return false unless commit - project.repository.is_ancestor?(commit.id, sha) + # Before 8.10, deployments didn't have keep-around refs. Any deployment + # created before then could have a `sha` referring to a commit that no + # longer exists in the repository, so just ignore those. + begin + project.repository.is_ancestor?(commit.id, sha) + rescue Rugged::OdbError + false + end end def update_merge_request_metrics! |