Skip to content

Commit

Permalink
Add support for abbreviated commit IDs (#10)
Browse files Browse the repository at this point in the history
Support shorter commit IDs than 40 characters
  • Loading branch information
odinuge authored and unknwon committed Jun 3, 2016
1 parent 0888f00 commit 1f1117c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions repo_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f1117c

Please sign in to comment.