From 1490933090166d71ce009708a70a16b156415052 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 2 Oct 2018 13:10:56 +0200 Subject: Expose paths modified by a push from a pipeline class --- app/models/ci/pipeline.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'app/models/ci/pipeline.rb') diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 6dac577c514..c0fb79a37e2 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -627,6 +627,18 @@ module Ci end end + def branch_updated? + strong_memoize(:branch_updated) do + push_details.branch_updated? + end + end + + def modified_paths + strong_memoize(:changes) do + push_details.modified_paths + end + end + private def ci_yaml_from_repo @@ -650,6 +662,22 @@ module Ci Gitlab::DataBuilder::Pipeline.build(self) end + def push_details + strong_memoize(:push_details) do + Gitlab::Git::Push.new(project, before_sha, sha, push_ref) + end + end + + def push_ref + if branch? + Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s + elsif tag? + Gitlab::Git::TAG_REF_PREFIX + ref.to_s + else + raise ArgumentError, 'Invalid pipeline type!' + end + end + def latest_builds_status return 'failed' unless yaml_errors.blank? -- cgit v1.2.1 From 4000358531668e07021160e436f3cdc1b873e9d7 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 3 Oct 2018 12:21:41 +0200 Subject: Few minor fixed in code and docs for only: changes --- app/models/ci/pipeline.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/ci/pipeline.rb') diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index c0fb79a37e2..a51745d41bb 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -634,7 +634,7 @@ module Ci end def modified_paths - strong_memoize(:changes) do + strong_memoize(:modified_paths) do push_details.modified_paths end end -- cgit v1.2.1