@@ -10,6 +10,7 @@ import (
1010 "strings"
1111
1212 giturl "code.gitea.io/gitea/modules/git/url"
13+ "code.gitea.io/gitea/modules/util"
1314)
1415
1516// CommitSubmoduleFile represents a file with submodule type.
@@ -28,6 +29,10 @@ func NewCommitSubmoduleFile(repoLink, fullPath, refURL, refID string) *CommitSub
2829 return & CommitSubmoduleFile {repoLink : repoLink , fullPath : fullPath , refURL : refURL , refID : refID }
2930}
3031
32+ func (sf * CommitSubmoduleFile ) RefID () string {
33+ return sf .refID
34+ }
35+
3136func (sf * CommitSubmoduleFile ) getWebLinkInTargetRepo (ctx context.Context , moreLinkPath string ) * SubmoduleWebLink {
3237 if sf == nil {
3338 return nil
@@ -47,17 +52,12 @@ func (sf *CommitSubmoduleFile) getWebLinkInTargetRepo(ctx context.Context, moreL
4752 return & SubmoduleWebLink {RepoWebLink : sf .parsedTargetLink , CommitWebLink : sf .parsedTargetLink + moreLinkPath }
4853}
4954
50- // RefID returns the commit ref id of the submodule file , it also works on "nil" receiver
51- func (sf * CommitSubmoduleFile ) RefID () string {
55+ // SubmoduleWebLinkTree tries to make the submodule's tree link in its own repo , it also works on "nil" receiver
56+ func (sf * CommitSubmoduleFile ) SubmoduleWebLinkTree ( ctx context. Context , optCommitID ... string ) * SubmoduleWebLink {
5257 if sf == nil {
53- return ""
58+ return nil
5459 }
55- return sf .refID
56- }
57-
58- // SubmoduleWebLinkTree tries to make the submodule's tree link in its own repo, it also works on "nil" receiver
59- func (sf * CommitSubmoduleFile ) SubmoduleWebLinkTree (ctx context.Context , refCommitID string ) * SubmoduleWebLink {
60- return sf .getWebLinkInTargetRepo (ctx , "/tree/" + refCommitID )
60+ return sf .getWebLinkInTargetRepo (ctx , "/tree/" + util .OptionalArg (optCommitID , sf .refID ))
6161}
6262
6363// SubmoduleWebLinkCompare tries to make the submodule's compare link in its own repo, it also works on "nil" receiver
0 commit comments