Fix: return correct type in GetSubModule

- `GetSubModules` already solely stores the URL of the submodule and not
a `*SubModule` entry, so don't try to type assert it to be a struct.
- I am not able to pinpoint when this was regressed but if I had to
guess it might be #4941.
- Added integration test.
This commit is contained in:
Gusted 2024-12-02 00:43:54 +01:00
parent fe246cc060
commit e7cffc378f
No known key found for this signature in database
GPG key ID: FD821B732837125F
4 changed files with 46 additions and 12 deletions

View file

@ -395,20 +395,20 @@ func parseSubmoduleContent(bs []byte) (*ObjectCache, error) {
return submoduleCache, nil
}
// GetSubModule get the sub module according entryname
func (c *Commit) GetSubModule(entryname string) (*SubModule, error) {
// GetSubModule returns the URL to the submodule according entryname
func (c *Commit) GetSubModule(entryname string) (string, error) {
modules, err := c.GetSubModules()
if err != nil {
return nil, err
return "", err
}
if modules != nil {
module, has := modules.Get(entryname)
if has {
return module.(*SubModule), nil
return module.(string), nil
}
}
return nil, nil
return "", nil
}
// GetBranchName gets the closest branch name (as returned by 'git name-rev --name-only')