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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user