mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-05 10:51:49 +09:00
Backport #39274 Co-authored-by: KBS <youdie006@naver.com>
This commit is contained in:
@@ -46,11 +46,11 @@ func (sf *CommitSubmoduleFile) getWebLinkInTargetRepo(ctx context.Context, moreL
|
||||
return &SubmoduleWebLink{RepoWebLink: targetLink, CommitWebLink: targetLink + moreLinkPath}
|
||||
}
|
||||
if !sf.parsed {
|
||||
sf.parsed = true
|
||||
parsedURL, err := giturl.ParseRepositoryURL(ctx, sf.refURL)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil // do not mark as parsed, otherwise later calls would return a link with an empty target
|
||||
}
|
||||
sf.parsed = true
|
||||
sf.parsedTargetLink = giturl.MakeRepositoryWebLink(parsedURL)
|
||||
}
|
||||
return &SubmoduleWebLink{RepoWebLink: sf.parsedTargetLink, CommitWebLink: sf.parsedTargetLink + moreLinkPath}
|
||||
|
||||
@@ -37,4 +37,11 @@ func TestCommitSubmoduleLink(t *testing.T) {
|
||||
assert.Equal(t, "/subpath/user/repo", wl.RepoWebLink)
|
||||
assert.Equal(t, "/subpath/user/repo/compare/1111...2222", wl.CommitWebLink)
|
||||
})
|
||||
|
||||
t.Run("UnparsableURL", func(t *testing.T) {
|
||||
// both calls share one instance on purpose: the second one used to see the cached parse result
|
||||
sf := NewCommitSubmoduleFile("/any/repo-link", "full-path", "git@github.com:", "aaaa")
|
||||
assert.Nil(t, sf.SubmoduleWebLinkTree(t.Context()))
|
||||
assert.Nil(t, sf.SubmoduleWebLinkCompare(t.Context(), "1111", "2222"))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user