diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-28 16:13:04 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-28 16:13:04 +0300 |
commit | 419d8cc7a2d0e5ffd2f3f8894a739827d0c2c549 (patch) | |
tree | 5a8eb71822918f3c11375b3a588e13455c164ed1 /lib/gitlab/git | |
parent | 4abba28944803d9a818925e62211a0f65458e011 (diff) |
Calculate modified paths of a git push operation
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r-- | lib/gitlab/git/diff_stats_collection.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/git/push.rb | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/git/diff_stats_collection.rb b/lib/gitlab/git/diff_stats_collection.rb index d4033f56387..998c41497a2 100644 --- a/lib/gitlab/git/diff_stats_collection.rb +++ b/lib/gitlab/git/diff_stats_collection.rb @@ -18,6 +18,10 @@ module Gitlab indexed_by_path[path] end + def paths + @collection.map(&:path) + end + private def indexed_by_path diff --git a/lib/gitlab/git/push.rb b/lib/gitlab/git/push.rb index b6e414927ea..603f860e4f8 100644 --- a/lib/gitlab/git/push.rb +++ b/lib/gitlab/git/push.rb @@ -28,6 +28,10 @@ module Gitlab Gitlab::Git.blank_ref?(@newrev) end + def branch_updated? + branch_push? && !branch_added? && !branch_removed? + end + def force_push? Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev) end @@ -37,6 +41,16 @@ module Gitlab Gitlab::Git.branch_ref?(@ref) end end + + def modified_paths + unless branch_updated? + raise ArgumentError, 'Unable to calculate modified paths!' + end + + strong_memoize(:modified_paths) do + @project.repository.diff_stats(@oldrev, @newrev).paths + end + end end end end |