-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add submodule diff links #33097
base: main
Are you sure you want to change the base?
add submodule diff links #33097
Conversation
This adds links to submodules in diffs, similar to the existing link when viewing a repo at a specific commit. It does this by expanding diff parsing to recognize changes to submodules, and find the specific refs that are added, deleted or changed. The templates are updated to add either a link to the submodule at a commit, or the diff between two commits in the event that the submodule is updated. A slight refactor was done to simplify calling RefURL on the submodule.
ps: we need this one first: Make git clone URL could use current signed-in user #33091 : it make the Git URL parsing more general ( |
Made some changes in 8d63859:
ps: need this one "Make git clone URL could use current signed-in user #33091" to rewrite |
func (si *SubmoduleInfo) RefID() string { | ||
if si.NewRefID != "" { | ||
return si.NewRefID | ||
} | ||
return si.PreviousRefID | ||
} | ||
|
||
// RefURL guesses and returns reference URL. | ||
func (si *SubmoduleInfo) RefURL(repoFullName string) string { | ||
return git.NewCommitSubModuleFile(si.SubmoduleURL, si.RefID()).RefURL(repoFullName) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question here: why it should introduce RefID
and use the if
trick? It seems quite unclear.
And for the "deletion" case, I do not think git.NewCommitSubModuleFile(si.SubmoduleURL, si.RefID())
would work because the submodule config should have been deleted? So no way to construct a link by this approach?
This adds links to submodules in diffs, similar to the existing link when viewing a repo at a specific commit. It does this by expanding diff parsing to recognize changes to submodules, and find the specific refs that are added, deleted or changed.
The templates are updated to add either a link to the submodule at a commit, or the diff between two commits in the event that the submodule is updated.
A slight refactor was done to simplify calling
RefURL
on the submodule. There was also aFIXME
comment in the template that said this should be updated to account forsetting.AppSubURL
. I tested this in an environment that uses a non defaultsetting.AppSubURL
, and verified that it works.Related #25888