summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-09-26 12:14:42 -0500
committerJose Ivan Vargas <jvargas@gitlab.com>2017-09-26 12:14:42 -0500
commitb4af546820b00537c6a5053f6b21dc9805dc11c7 (patch)
tree505745bec506be527c7a0e940b754b0960c77167 /app/models/commit.rb
parent7fb477325eb7f1215a6ae128c9a3a300606d7fbe (diff)
parent3b2d68d37d39047e25fbe0ae51cafa39f22805f8 (diff)
downloadgitlab-ce-b4af546820b00537c6a5053f6b21dc9805dc11c7.tar.gz
Merge branch 'master' into sh-headless-chrome-support
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb11
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