Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit 8503974

Browse files
lunnylafriks
authored andcommitted
add commit structs (#138)
1 parent a07993c commit 8503974

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

gitea/repo_commit.go

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

0 commit comments

Comments
 (0)