Revert "API split for: to get single commit via SHA and Ref (#319)" (#324)

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:
6543 2020-05-11 19:03:14 +00:00 committed by Andrew Thornton
parent fb7355a186
commit 2883376503

View file

@ -8,7 +8,6 @@ package gitea
import (
"fmt"
"net/url"
"regexp"
"time"
)
@ -55,17 +54,11 @@ type CommitDateOptions struct {
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
func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) {
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/commits/%s", user, repo, commitID), nil, nil, &commit)
}
// ListCommitOptions list commit options
type ListCommitOptions struct {