summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-04 10:48:38 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-04 10:48:38 +0200
commit876c6f24919926f423c5e3521375fcc63ad0fdf1 (patch)
tree5436b8948a7f1ea7f3917586f7bd1234b8888014 /lib
parent5cab9d6fd88eecbac52424e3b392e7b75d98507b (diff)
parent11357c8bb2f019a4c8100edcf6dca004098b6f1e (diff)
downloadgitlab-ce-876c6f24919926f423c5e3521375fcc63ad0fdf1.tar.gz
Merge branch 'master' of github.com:gitlabhq/gitlabhq
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git.rb5
-rw-r--r--lib/gitlab/git_access.rb4
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb
new file mode 100644
index 00000000000..67aca5e36e9
--- /dev/null
+++ b/lib/gitlab/git.rb
@@ -0,0 +1,5 @@
+module Gitlab
+ module Git
+ BLANK_SHA = '0' * 40
+ end
+end
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index b768a99a0e8..129881060d5 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -67,7 +67,7 @@ module Gitlab
if forced_push?(project, oldrev, newrev)
:force_push_code_to_protected_branches
# and we dont allow remove of protected branch
- elsif newrev =~ /0000000/
+ elsif newrev == Gitlab::Git::BLANK_SHA
:remove_protected_branches
else
:push_code_to_protected_branches
@@ -85,7 +85,7 @@ module Gitlab
def forced_push?(project, oldrev, newrev)
return false if project.empty_repo?
- if oldrev !~ /00000000/ && newrev !~ /00000000/
+ if oldrev != Gitlab::Git::BLANK_SHA && newrev != Gitlab::Git::BLANK_SHA
missed_refs = IO.popen(%W(git --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev})).read
missed_refs.split("\n").size > 0
else