Merge branch 'master' into revert-commit-api-split
Revert "API split for: to get single commit via SHA and Ref (#319)"
This reverts commit 36d2964230
.
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/324
Reviewed-by: lafriks <lafriks@noreply.gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
fb7355a186
commit
2883376503
1 changed files with 1 additions and 8 deletions
|
@ -8,7 +8,6 @@ package gitea
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,16 +54,10 @@ type CommitDateOptions struct {
|
||||||
Committer time.Time `json:"committer"`
|
Committer time.Time `json:"committer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHAPattern can be used to determine if a string is an valid sha
|
|
||||||
var SHAPattern = regexp.MustCompile(`^[0-9a-f]{4,40}$`)
|
|
||||||
|
|
||||||
// GetSingleCommit returns a single commit
|
// GetSingleCommit returns a single commit
|
||||||
func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) {
|
func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) {
|
||||||
commit := new(Commit)
|
commit := new(Commit)
|
||||||
if e := c.CheckServerVersionConstraint("<1.12.0"); e == nil || SHAPattern.MatchString(commitID) {
|
return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/commits/%s", user, repo, commitID), nil, nil, &commit)
|
||||||
return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/commits/%s", user, repo, commitID), nil, nil, &commit)
|
|
||||||
}
|
|
||||||
return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s", user, repo, commitID), nil, nil, &commit)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListCommitOptions list commit options
|
// ListCommitOptions list commit options
|
||||||
|
|
Loading…
Reference in a new issue