From 08bbb9fce66cb46d3262e6cd4c4379b59f065be0 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 9 Mar 2017 19:29:11 -0600 Subject: Add option to start a new discussion on an MR --- app/models/commit.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index ce92cc369ad..5c452f78546 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -2,6 +2,7 @@ class Commit extend ActiveModel::Naming include ActiveModel::Conversion + include Noteable include Participable include Mentionable include Referable @@ -203,6 +204,10 @@ class Commit project.notes.for_commit_id(self.id) end + def discussion_notes + notes.non_diff_notes + end + def notes_with_associations notes.includes(:author) end -- cgit v1.2.1 From d6cc8feb6ce0a8e39a1bc8830b932155713357da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Tue, 28 Mar 2017 22:23:45 -0300 Subject: Setup and run a Gitaly server for testing if GitalyClient is enabled --- app/models/commit.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 5c452f78546..8b8b3f00202 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -326,14 +326,13 @@ class Commit end def raw_diffs(*args) - use_gitaly = Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) - deltas_only = args.last.is_a?(Hash) && args.last[:deltas_only] - - if use_gitaly && !deltas_only - Gitlab::GitalyClient::Commit.diff_from_parent(self, *args) - else - raw.diffs(*args) - end + # NOTE: This feature is intentionally disabled until + # https://gitlab.com/gitlab-org/gitaly/issues/178 is resolved + # if Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) + # Gitlab::GitalyClient::Commit.diff_from_parent(self, *args) + # else + raw.diffs(*args) + # end end def diffs(diff_options = nil) -- cgit v1.2.1 From 7f625f06d333cbe3846081924a3e7016b2846ae0 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 13 Apr 2017 11:59:52 -0500 Subject: Pass project to Blob --- app/models/commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 8b8b3f00202..bb4cb8efd15 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -316,7 +316,7 @@ class Commit def uri_type(path) entry = @raw.tree.path(path) if entry[:type] == :blob - blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name])) + blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), @project) blob.image? || blob.video? ? :raw : :blob else entry[:type] -- cgit v1.2.1 From e69a7b95df4aea964878086157487379705c9a8c Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 3 May 2017 00:10:17 +0800 Subject: Always show latest pipeline info in commit box --- app/models/commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index bb4cb8efd15..e37c2d6bbd6 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -237,7 +237,7 @@ class Commit end def latest_pipeline - pipelines.last + @latest_pipeline ||= pipelines.last end def status(ref = nil) -- cgit v1.2.1 From 0a29bde4a1c2c77c49c3fa28ca3f059ba3d3b7d5 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 3 May 2017 01:40:20 +0800 Subject: Rename latest_pipeline to last_pipeline As it might be confusing that it's not the same as Pipeline#latest Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11038#note_28677090 --- app/models/commit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index e37c2d6bbd6..88a015cdb77 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -236,8 +236,8 @@ class Commit project.pipelines.where(sha: sha) end - def latest_pipeline - @latest_pipeline ||= pipelines.last + def last_pipeline + @last_pipeline ||= pipelines.last end def status(ref = nil) -- cgit v1.2.1 From 34cd10979757cdad26056a532cf09c59a7f74ae9 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Fri, 21 Apr 2017 15:02:21 +0200 Subject: Re-enable Gitaly commit_raw_diff feature --- app/models/commit.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 88a015cdb77..9359b323ed4 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -326,13 +326,14 @@ class Commit end def raw_diffs(*args) - # NOTE: This feature is intentionally disabled until - # https://gitlab.com/gitlab-org/gitaly/issues/178 is resolved - # if Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) - # Gitlab::GitalyClient::Commit.diff_from_parent(self, *args) - # else - raw.diffs(*args) - # end + use_gitaly = Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) + deltas_only = args.last.is_a?(Hash) && args.last[:deltas_only] + + if use_gitaly && !deltas_only + Gitlab::GitalyClient::Commit.diff_from_parent(self, *args) + else + raw.diffs(*args) + end end def diffs(diff_options = nil) -- cgit v1.2.1 From 48254d187f421dfeb85a84bf2b86399add6e6a67 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 9 May 2017 12:27:17 +0200 Subject: Don't use DiffCollection for deltas --- app/models/commit.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 9359b323ed4..e1da8e75c0c 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -373,7 +373,7 @@ class Commit def repo_changes changes = { added: [], modified: [], removed: [] } - raw_diffs(deltas_only: true).each do |diff| + raw_deltas.each do |diff| if diff.deleted_file changes[:removed] << diff.old_path elsif diff.renamed_file || diff.new_file @@ -386,6 +386,10 @@ class Commit changes end + def raw_deltas + raw.deltas + end + def merged_merge_request?(user) !!merged_merge_request(user) end -- cgit v1.2.1 From f1a14d685702bc8ea29791cda8440c3bab3c14a1 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 9 May 2017 13:48:21 +0200 Subject: Don't make Commit#raw_deltas private --- app/models/commit.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index e1da8e75c0c..e31ca64cee9 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -336,6 +336,10 @@ class Commit end end + def raw_deltas + raw.deltas + end + def diffs(diff_options = nil) Gitlab::Diff::FileCollection::Commit.new(self, diff_options: diff_options) end @@ -386,10 +390,6 @@ class Commit changes end - def raw_deltas - raw.deltas - end - def merged_merge_request?(user) !!merged_merge_request(user) end -- cgit v1.2.1 From 3107f2e460d8db35f7ddd0cc5f68575233bfc133 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 9 May 2017 14:44:15 +0200 Subject: Use Rails 'delegate' --- app/models/commit.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index e31ca64cee9..dea18bfedef 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -336,9 +336,7 @@ class Commit end end - def raw_deltas - raw.deltas - end + delegate :deltas, to: :raw, prefix: :raw def diffs(diff_options = nil) Gitlab::Diff::FileCollection::Commit.new(self, diff_options: diff_options) -- cgit v1.2.1 From d40e1f547ea9e31e822229bb808aaa6b9201f473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 3 May 2017 13:22:03 +0200 Subject: Enable the Style/TrailingCommaInLiteral cop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the EnforcedStyleForMultiline: no_comma option. Signed-off-by: Rémy Coutable --- app/models/commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index dea18bfedef..3a143a5a1f6 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -49,7 +49,7 @@ class Commit def max_diff_options { max_files: DIFF_HARD_LIMIT_FILES, - max_lines: DIFF_HARD_LIMIT_LINES, + max_lines: DIFF_HARD_LIMIT_LINES } end -- cgit v1.2.1 From 27fb64d6a33ea61ba5a0a3ad50babff8c30fa45f Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 11 May 2017 10:52:45 +0200 Subject: Remove deltas_only from DiffCollection --- app/models/commit.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 3a143a5a1f6..8d54ce6eb25 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -326,10 +326,7 @@ class Commit end def raw_diffs(*args) - use_gitaly = Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) - deltas_only = args.last.is_a?(Hash) && args.last[:deltas_only] - - if use_gitaly && !deltas_only + if Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) Gitlab::GitalyClient::Commit.diff_from_parent(self, *args) else raw.diffs(*args) -- cgit v1.2.1 From 99feed6e00e0f012f7e879a710e8b478b6160d2f Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Fri, 5 May 2017 16:55:12 +0200 Subject: Add support for deltas_only under Gitaly Closes gitaly#199 --- app/models/commit.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 8d54ce6eb25..dbc0a22829e 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -327,13 +327,21 @@ class Commit def raw_diffs(*args) if Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) - Gitlab::GitalyClient::Commit.diff_from_parent(self, *args) + Gitlab::GitalyClient::Commit.new(project.repository).diff_from_parent(self, *args) else raw.diffs(*args) end end - delegate :deltas, to: :raw, prefix: :raw + def raw_deltas + @deltas ||= Gitlab::GitalyClient.migrate(:commit_deltas) do |is_enabled| + if is_enabled + Gitlab::GitalyClient::Commit.new(project.repository).commit_deltas(self) + else + raw.deltas + end + end + end def diffs(diff_options = nil) Gitlab::Diff::FileCollection::Commit.new(self, diff_options: diff_options) -- cgit v1.2.1