1
0
mirror of https://github.com/go-gitea/git.git synced 2026-02-05 15:45:40 +01:00

Add support for abbreviated commit IDs (#10)

Support shorter commit IDs than 40 characters
This commit is contained in:
Odin Ugedal
2016-06-03 03:16:23 +02:00
committed by Unknwon
parent 0888f003de
commit 1f1117c396

View File

@@ -110,6 +110,13 @@ func (repo *Repository) getCommit(id sha1) (*Commit, error) {
// GetCommit returns commit object of by ID string.
func (repo *Repository) GetCommit(commitID string) (*Commit, error) {
if len(commitID) != 40 {
var err error
commitID, err = NewCommand("rev-parse", commitID).RunInDir(repo.Path)
if err != nil {
return nil, err
}
}
id, err := NewIDFromString(commitID)
if err != nil {
return nil, err