From 3c2d6b4870afa9cae25007a2ccf90ebf92c37d42 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 28 Sep 2018 11:00:30 +0200 Subject: Add a class that represents a git push operation --- lib/gitlab/git/push.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/gitlab/git/push.rb (limited to 'lib') 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 -- cgit v1.2.1