mirror of
https://github.com/go-gitea/gitea
synced 2025-07-16 07:18:37 +00:00
Use gitrepo.GetTreePathLatestCommit to get file lastest commit instead from latest commit cache (#32987) (#33046)
This commit is contained in:
@@ -62,3 +62,14 @@ func (repo *Repository) LsTree(ref string, filenames ...string) ([]string, error
|
||||
|
||||
return filelist, err
|
||||
}
|
||||
|
||||
// GetTreePathLatestCommitID returns the latest commit of a tree path
|
||||
func (repo *Repository) GetTreePathLatestCommit(refName, treePath string) (*Commit, error) {
|
||||
stdout, _, err := NewCommand(repo.Ctx, "rev-list", "-1").
|
||||
AddDynamicArguments(refName).AddDashesAndList(treePath).
|
||||
RunStdString(&RunOpts{Dir: repo.Path})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return repo.GetCommit(strings.TrimSpace(stdout))
|
||||
}
|
||||
|
Reference in New Issue
Block a user