Skip to content

Commit

Permalink
feat(git): only generate line numbers > 0 (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgmz committed Oct 18, 2023
1 parent 6ea3a7d commit b46fb75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/giturl/giturl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
8 changes: 8 additions & 0 deletions pkg/giturl/giturl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit b46fb75

Please sign in to comment.