Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-03-18 18:37:29 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-19 00:08:22 +0300
commit8b17fcb89715007e6877f676225fcce3bd909c83 (patch)
tree8d0e86c9b1a5d0606248d178b50e6467b2b9852d
parent09657f1071571ca6a2ef7dd844e3e930dcb4a27e (diff)
Fix condensed range in MR push comment.
-rw-r--r--app/models/note.rb8
-rw-r--r--app/services/merge_requests/refresh_service.rb2
2 files changed, 7 insertions, 3 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 9ca3e4d7e97..649e9b4e852 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -151,7 +151,7 @@ class Note < ActiveRecord::Base
)
end
- def create_new_commits_note(merge_request, project, author, new_commits, existing_commits = [])
+ def create_new_commits_note(merge_request, project, author, new_commits, existing_commits = [], oldrev = nil)
total_count = new_commits.length + existing_commits.length
commits_text = ActionController::Base.helpers.pluralize(total_count, 'commit')
body = "Added #{commits_text}:\n\n"
@@ -161,7 +161,11 @@ class Note < ActiveRecord::Base
if existing_commits.length == 1
existing_commits.first.short_id
else
- "#{existing_commits.first.short_id}..#{existing_commits.last.short_id}"
+ if oldrev
+ "#{Commit.truncate_sha(oldrev)}...#{existing_commits.last.short_id}"
+ else
+ "#{existing_commits.first.short_id}..#{existing_commits.last.short_id}"
+ end
end
commits_text = ActionController::Base.helpers.pluralize(existing_commits.length, 'commit')
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index cab8a1e880e..7eef2c2d6a5 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -89,7 +89,7 @@ module MergeRequests
end
Note.create_new_commits_note(merge_request, merge_request.project,
- @current_user, new_commits, existing_commits)
+ @current_user, new_commits, existing_commits, @oldrev)
end
end