mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 07:04:24 +00:00
feat(git): only generate line numbers > 0 (#1898)
This commit is contained in:
parent
6ea3a7da4a
commit
b46fb75c73
2 changed files with 13 additions and 0 deletions
|
@ -158,6 +158,11 @@ func UpdateLinkLineNumber(ctx context.Context, link string, newLine int64) strin
|
|||
return link
|
||||
}
|
||||
|
||||
if newLine <= 0 {
|
||||
// Don't change the link if the line number is 0.
|
||||
return link
|
||||
}
|
||||
|
||||
switch determineProvider(link) {
|
||||
case providerBitbucket:
|
||||
// For Bitbucket, it doesn't support line links (based on the GenerateLink function).
|
||||
|
|
|
@ -251,6 +251,14 @@ func TestUpdateLinkLineNumber(t *testing.T) {
|
|||
},
|
||||
want: "https://onprem.customdomain.com/org/repo/commit/xyz123#L50",
|
||||
},
|
||||
{
|
||||
name: "Don't include line when it's 0",
|
||||
args: args{
|
||||
link: "https://github.com/coinbase/cbpay-js/issues/181",
|
||||
newLine: int64(0),
|
||||
},
|
||||
want: "https://github.com/coinbase/cbpay-js/issues/181",
|
||||
},
|
||||
{
|
||||
name: "Invalid link",
|
||||
args: args{
|
||||
|
|
Loading…
Reference in a new issue