diff options
author | Unknwon <u@gogs.io> | 2018-06-03 20:26:29 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2018-06-03 20:26:29 +0800 |
commit | 8d091ec062815dfd885c540d107ac2e07ed6b880 (patch) | |
tree | d91ac36cb014730deaaff918557d81c8f9b3041d /vendor/github.com/gogs/git-module | |
parent | 0376e59520a8538291e3b571142aa6ce0a8682de (diff) |
vendor: update github.com/gogs/git-module
Diffstat (limited to 'vendor/github.com/gogs/git-module')
-rw-r--r-- | vendor/github.com/gogs/git-module/commit.go | 16 | ||||
-rw-r--r-- | vendor/github.com/gogs/git-module/git.go | 2 | ||||
-rw-r--r-- | vendor/github.com/gogs/git-module/repo_commit.go | 13 |
3 files changed, 21 insertions, 10 deletions
diff --git a/vendor/github.com/gogs/git-module/commit.go b/vendor/github.com/gogs/git-module/commit.go index cab9f464..45c3437b 100644 --- a/vendor/github.com/gogs/git-module/commit.go +++ b/vendor/github.com/gogs/git-module/commit.go @@ -303,3 +303,19 @@ func GetCommitFileStatus(repoPath, commitID string) (*CommitFileStatus, error) { func (c *Commit) FileStatus() (*CommitFileStatus, error) { return GetCommitFileStatus(c.repo.Path, c.ID.String()) } + +// GetFullCommitID returns full length (40) of commit ID by given short SHA in a repository. +func GetFullCommitID(repoPath, shortID string) (string, error) { + if len(shortID) >= 40 { + return shortID, nil + } + + commitID, err := NewCommand("rev-parse", shortID).RunInDir(repoPath) + if err != nil { + if strings.Contains(err.Error(), "exit status 128") { + return "", ErrNotExist{shortID, ""} + } + return "", err + } + return strings.TrimSpace(commitID), nil +} diff --git a/vendor/github.com/gogs/git-module/git.go b/vendor/github.com/gogs/git-module/git.go index 1b2628e9..7d54d66e 100644 --- a/vendor/github.com/gogs/git-module/git.go +++ b/vendor/github.com/gogs/git-module/git.go @@ -10,7 +10,7 @@ import ( "time" ) -const _VERSION = "0.6.5" +const _VERSION = "0.6.6" func Version() string { return _VERSION diff --git a/vendor/github.com/gogs/git-module/repo_commit.go b/vendor/github.com/gogs/git-module/repo_commit.go index 1ac03387..efbc8700 100644 --- a/vendor/github.com/gogs/git-module/repo_commit.go +++ b/vendor/github.com/gogs/git-module/repo_commit.go @@ -126,15 +126,10 @@ 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 { - if strings.Contains(err.Error(), "exit status 128") { - return nil, ErrNotExist{commitID, ""} - } - return nil, err - } + var err error + commitID, err = GetFullCommitID(repo.Path, commitID) + if err != nil { + return nil, fmt.Errorf("GetCommitFullID: %v", err) } id, err := NewIDFromString(commitID) if err != nil { |