diff options
Diffstat (limited to 'modules/git/repo_branch.go')
-rw-r--r-- | modules/git/repo_branch.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go index 14dcf14d8a..3bb6ef5223 100644 --- a/modules/git/repo_branch.go +++ b/modules/git/repo_branch.go @@ -106,6 +106,17 @@ func GetBranchesByPath(ctx context.Context, path string, skip, limit int) ([]*Br return gitRepo.GetBranches(skip, limit) } +// GetBranchCommitID returns a branch commit ID by its name +func GetBranchCommitID(ctx context.Context, path, branch string) (string, error) { + gitRepo, err := OpenRepository(ctx, path) + if err != nil { + return "", err + } + defer gitRepo.Close() + + return gitRepo.GetBranchCommitID(branch) +} + // GetBranches returns a slice of *git.Branch func (repo *Repository) GetBranches(skip, limit int) ([]*Branch, int, error) { brs, countAll, err := repo.GetBranchNames(skip, limit) |