Skip to content
Snippets Groups Projects
Commit 4374a38f authored by micael.bergeron's avatar micael.bergeron
Browse files

fix the commit reference pattern from matching other entities

parent a4072db0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -26,7 +26,7 @@ class Commit
DIFF_HARD_LIMIT_LINES = 50000
 
MIN_SHA_LENGTH = 7
COMMIT_SHA_PATTERN = /\h{#{MIN_SHA_LENGTH},40}/.freeze
COMMIT_SHA_PATTERN = /\b(?<![~#!@:])\h{#{MIN_SHA_LENGTH},40}/.freeze
 
def banzai_render_context(field)
context = { pipeline: :single_line, project: self.project }
Loading
Loading
---
title: Label addition/removal are not going to be redacted wrongfully in the API.
merge_request: 15080
author:
type: fixed
Loading
Loading
@@ -468,4 +468,27 @@ eos
expect(described_class.valid_hash?('a' * 41)).to be false
end
end
describe '.reference_pattern' do
where(:ref, :matches?) do
sha = Digest::SHA1.hexdigest 'thisisacommitid'
[
[sha.first(Commit::MIN_SHA_LENGTH - 1), false],
[sha.first(Commit::MIN_SHA_LENGTH), true],
[sha, true],
['~' << sha, false], # labels
['!' << sha, false], # merge_request
[':' << sha, false], # emoji
['#' << sha, false], # issue
['@' << sha, false], # user
]
end
with_them do
it "should match only on commit references" do
expect(Commit.reference_pattern.match(ref).present?).to eq(matches?)
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment