repo_commit.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2018 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package gogs
  5. import (
  6. "fmt"
  7. )
  8. // CommitMeta contains meta information of a commit in terms of API.
  9. type CommitMeta struct {
  10. URL string `json:"url"`
  11. SHA string `json:"sha"`
  12. }
  13. // CommitUser contains information of a user in the context of a commit.
  14. type CommitUser struct {
  15. Name string `json:"name"`
  16. Email string `json:"email"`
  17. Date string `json:"date"`
  18. }
  19. // RepoCommit contains information of a commit in the context of a repository.
  20. type RepoCommit struct {
  21. URL string `json:"url"`
  22. Author *CommitUser `json:"author"`
  23. Committer *CommitUser `json:"committer"`
  24. Message string `json:"message"`
  25. Tree *CommitMeta `json:"tree"`
  26. }
  27. // Commit contains information generated from a Git commit.
  28. type Commit struct {
  29. *CommitMeta
  30. HTMLURL string `json:"html_url"`
  31. RepoCommit *RepoCommit `json:"commit"`
  32. Author *User `json:"author"`
  33. Committer *User `json:"committer"`
  34. Parents []*CommitMeta `json:"parents"`
  35. }
  36. func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) {
  37. commit := new(Commit)
  38. return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s", user, repo, commitID), nil, nil, &commit)
  39. }