diff options
author | Robert Speicher <robert@gitlab.com> | 2017-09-26 14:16:46 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-09-26 14:16:46 +0000 |
commit | d0606b5ff4a7f2ce9209583d7e45a2266ab09cd3 (patch) | |
tree | 70bc952a8d3cd77474a3917771613c445b4440a6 /app/models | |
parent | 7e71ec199a3aa0852bfdf7f8bb39d96448a58258 (diff) | |
parent | c19030332c334a0fda787f2df6bd13a977b62039 (diff) | |
download | gitlab-ce-d0606b5ff4a7f2ce9209583d7e45a2266ab09cd3.tar.gz |
Merge branch 'dm-bitbucket-import-truncated-shas' into 'master'
Fix bug that caused merge requests with diff notes imported from Bitbucket to raise errors
Closes #38100
See merge request gitlab-org/gitlab-ce!14438
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 2ae8890c1b3..6dba154a6ea 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -25,8 +25,8 @@ class Commit DIFF_HARD_LIMIT_FILES = 1000 DIFF_HARD_LIMIT_LINES = 50000 - # The SHA can be between 7 and 40 hex characters. - COMMIT_SHA_PATTERN = '\h{7,40}'.freeze + MIN_SHA_LENGTH = 7 + COMMIT_SHA_PATTERN = /\h{#{MIN_SHA_LENGTH},40}/.freeze def banzai_render_context(field) context = { pipeline: :single_line, project: self.project } @@ -53,7 +53,7 @@ class Commit # Truncate sha to 8 characters def truncate_sha(sha) - sha[0..7] + sha[0..MIN_SHA_LENGTH] end def max_diff_options @@ -100,7 +100,7 @@ class Commit def self.reference_pattern @reference_pattern ||= %r{ (?:#{Project.reference_pattern}#{reference_prefix})? - (?<commit>\h{7,40}) + (?<commit>#{COMMIT_SHA_PATTERN}) }x end @@ -216,9 +216,8 @@ class Commit @raw.respond_to?(method, include_private) || super end - # Truncate sha to 8 characters def short_id - @raw.short_id(7) + @raw.short_id(MIN_SHA_LENGTH) end def diff_refs |