Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-09-28 12:00:30 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-09-28 12:09:55 +0300
commit3c2d6b4870afa9cae25007a2ccf90ebf92c37d42 (patch)
tree475015e2404da84793d1bdadc226fcd1bed28c11 /lib/gitlab/git
parentba66e0cc9cc26df686ed47d926a3edcde497baa1 (diff)
Add a class that represents a git push operation
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r--lib/gitlab/git/push.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/git/push.rb b/lib/gitlab/git/push.rb
new file mode 100644
index 00000000000..d4fe3c623c1
--- /dev/null
+++ b/lib/gitlab/git/push.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Git
+ class Push
+ def initialize(project, oldrev, newrev, ref)
+ @project, @oldrev, @newrev = project, oldrev, newrev
+ @repository = project.repository
+ @branch_name = Gitlab::Git.ref_name(ref)
+ end
+
+ def branch_added?
+ Gitlab::Git.blank_ref?(@oldrev)
+ end
+
+ def branch_removed?
+ Gitlab::Git.blank_ref?(@newrev)
+ end
+
+ def force_push?
+ Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev)
+ end
+ end
+ end
+end