aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/tree.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/tree.go')
-rw-r--r--modules/git/tree.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/git/tree.go b/modules/git/tree.go
index 1da4a9fa5d..d35dc58d8d 100644
--- a/modules/git/tree.go
+++ b/modules/git/tree.go
@@ -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))
+}