diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-15 12:10:29 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-23 15:37:04 -0500 |
commit | d9a0188d2f7dfc07b426d36eeebc2c94385c12ca (patch) | |
tree | bc824e6f0571823ca6b3bd55053c0f931ba740bc /lib | |
parent | 52527be4387cb978402a330f2e4de96e586a62db (diff) | |
download | gitlab-ce-d9a0188d2f7dfc07b426d36eeebc2c94385c12ca.tar.gz |
Add question mark to Gitlab::Diff::File predicate methods
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/diff/file.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/git/diff.rb | 8 |
3 files changed, 15 insertions, 8 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 01cc8e8e1ca..cf4affe1758 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -252,7 +252,9 @@ module API class RepoDiff < Grape::Entity expose :old_path, :new_path, :a_mode, :b_mode, :diff - expose :new_file, :renamed_file, :deleted_file + expose :new_file?, as: :new_file + expose :renamed_file?, as: :renamed_file + expose :deleted_file?, as: :deleted_file end class Milestone < ProjectEntity diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index c6bf25b5874..cb9fda36156 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -3,8 +3,8 @@ module Gitlab class File attr_reader :diff, :repository, :diff_refs - delegate :new_file, :deleted_file, :renamed_file, - :old_path, :new_path, :a_mode, :b_mode, + delegate :new_file?, :deleted_file?, :renamed_file?, + :old_path, :new_path, :a_mode, :b_mode, :mode_changed?, :submodule?, :too_large?, :collapsed?, to: :diff, prefix: false def initialize(diff, repository:, diff_refs: nil) @@ -85,10 +85,6 @@ module Gitlab @parallel_diff_lines ||= Gitlab::Diff::ParallelDiff.new(self).parallelize end - def mode_changed? - a_mode && b_mode && a_mode != b_mode - end - def raw_diff diff.diff.to_s end @@ -119,6 +115,7 @@ module Gitlab def old_blob(commit = old_content_commit) return unless commit + return if new_file? repository.blob_at(commit.id, old_path) end @@ -130,7 +127,7 @@ module Gitlab end def file_identifier - "#{file_path}-#{new_file}-#{deleted_file}-#{renamed_file}" + "#{file_path}-#{new_file?}-#{deleted_file?}-#{renamed_file?}" end end end diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb index 31d1b66b4f7..deade337354 100644 --- a/lib/gitlab/git/diff.rb +++ b/lib/gitlab/git/diff.rb @@ -11,6 +11,10 @@ module Gitlab # Stats properties attr_accessor :new_file, :renamed_file, :deleted_file + alias_method :new_file?, :new_file + alias_method :deleted_file?, :deleted_file + alias_method :renamed_file?, :renamed_file + attr_accessor :too_large # The maximum size of a diff to display. @@ -208,6 +212,10 @@ module Gitlab hash end + def mode_changed? + a_mode && b_mode && a_mode != b_mode + end + def submodule? a_mode == '160000' || b_mode == '160000' end |