summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-03-19 10:34:04 +0100
committerDouwe Maan <douwe@gitlab.com>2015-03-19 10:34:04 +0100
commita5a5ec970e0e8dc56103decd3a0f5fbf3db46bcb (patch)
treeadb5d12a1e56b06f724782ff893d0bb1bb4864e1 /lib
parent7ed6da5454c98e78770cee13ac929f5f608a34a1 (diff)
downloadgitlab-ce-a5a5ec970e0e8dc56103decd3a0f5fbf3db46bcb.tar.gz
Fewer constants, more helpers.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/force_push_check.rb7
-rw-r--r--lib/gitlab/push_data_builder.rb3
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/gitlab/force_push_check.rb b/lib/gitlab/force_push_check.rb
index eae9773a067..fdb6a35c78d 100644
--- a/lib/gitlab/force_push_check.rb
+++ b/lib/gitlab/force_push_check.rb
@@ -3,11 +3,12 @@ module Gitlab
def self.force_push?(project, oldrev, newrev)
return false if project.empty_repo?
- if oldrev != Gitlab::Git::BLANK_SHA && newrev != Gitlab::Git::BLANK_SHA
+ # Created or deleted branch
+ if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
+ false
+ else
missed_refs, _ = Gitlab::Popen.popen(%W(git --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev}))
missed_refs.split("\n").size > 0
- else
- false
end
end
end
diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb
index 694a30db5df..948cf58fd9a 100644
--- a/lib/gitlab/push_data_builder.rb
+++ b/lib/gitlab/push_data_builder.rb
@@ -71,7 +71,8 @@ module Gitlab
end
def checkout_sha(repository, newrev, ref)
- if newrev != Gitlab::Git::BLANK_SHA && Gitlab::Git.tag_ref?(ref)
+ # Find sha for tag, except when it was deleted.
+ if Gitlab::Git.tag_ref?(ref) && !Gitlab::Git.blank_ref?(newrev)
tag_name = Gitlab::Git.ref_name(ref)
tag = repository.find_tag(tag_name)