summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-03-19 15:53:43 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-03-19 15:53:43 +0000
commitc8a7e4c6c1406973b532d184e05f72e32f607326 (patch)
tree3403a7e6b1ced5331a43b549bd46f686a36cc157
parentc71fa13206d2eaac0324c842190b184249ed5e64 (diff)
parenta5a5ec970e0e8dc56103decd3a0f5fbf3db46bcb (diff)
downloadgitlab-ce-c8a7e4c6c1406973b532d184e05f72e32f607326.tar.gz
Merge branch 'fewer-constants-more-helpres' into 'master'
Fewer Git constants, more Git helpers. See merge request !1727
-rw-r--r--app/services/git_push_service.rb2
-rw-r--r--app/workers/irker_worker.rb6
-rw-r--r--lib/gitlab/force_push_check.rb7
-rw-r--r--lib/gitlab/push_data_builder.rb3
4 files changed, 10 insertions, 8 deletions
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index 4885e1b2fc5..a0da07f5c90 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -109,7 +109,7 @@ class GitPushService
def push_to_existing_branch?(ref, oldrev)
# Return if this is not a push to a branch (e.g. new commits)
- Gitlab::Git.branch_ref?(ref) && oldrev != Gitlab::Git::BLANK_SHA
+ Gitlab::Git.branch_ref?(ref) && !Gitlab::Git.blank_ref?(oldrev)
end
def push_to_new_branch?(ref, oldrev)
diff --git a/app/workers/irker_worker.rb b/app/workers/irker_worker.rb
index e1a99d9cad8..8b50f423984 100644
--- a/app/workers/irker_worker.rb
+++ b/app/workers/irker_worker.rb
@@ -57,9 +57,9 @@ class IrkerWorker
end
def send_branch_updates(push_data, project, repo_name, committer, branch)
- if push_data['before'] == Gitlab::Git::BLANK_SHA
+ if Gitlab::Git.blank_ref?(push_data['before'])
send_new_branch project, repo_name, committer, branch
- elsif push_data['after'] == Gitlab::Git::BLANK_SHA
+ elsif Gitlab::Git.blank_ref?(push_data['after'])
send_del_branch repo_name, committer, branch
end
end
@@ -83,7 +83,7 @@ class IrkerWorker
return if push_data['total_commits_count'] == 0
# Next message is for number of commit pushed, if any
- if push_data['before'] == Gitlab::Git::BLANK_SHA
+ if Gitlab::Git.blank_ref?(push_data['before'])
# Tweak on push_data["before"] in order to have a nice compare URL
push_data['before'] = before_on_new_branch push_data, project
end
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)