Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 61758ab

Browse files
committed
repo_commit: add GetSingleCommit (gogs/gogs#5546)
1 parent 2040be8 commit 61758ab

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

‎gogs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func Version() string {
17-
return "0.12.14"
17+
return "0.13.0"
1818
}
1919

2020
// Client represents a Gogs API client.

‎repo_commit.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
5+
package gogs
6+
7+
import (
8+
"fmt"
9+
)
10+
11+
// CommitMeta contains meta information of a commit in terms of API.
12+
type CommitMeta struct {
13+
URL string `json:"url"`
14+
SHA string `json:"sha"`
15+
}
16+
17+
// CommitUser contains information of a user in the context of a commit.
18+
type CommitUser struct {
19+
Name string `json:"name"`
20+
Email string `json:"email"`
21+
Date string `json:"date"`
22+
}
23+
24+
// RepoCommit contains information of a commit in the context of a repository.
25+
type RepoCommit struct {
26+
URL string `json:"url"`
27+
Author *CommitUser `json:"author"`
28+
Committer *CommitUser `json:"committer"`
29+
Message string `json:"message"`
30+
Tree *CommitMeta `json:"tree"`
31+
}
32+
33+
// Commit contains information generated from a Git commit.
34+
type Commit struct {
35+
*CommitMeta
36+
HTMLURL string `json:"html_url"`
37+
RepoCommit *RepoCommit `json:"commit"`
38+
Author *User `json:"author"`
39+
Committer *User `json:"committer"`
40+
Parents []*CommitMeta `json:"parents"`
41+
}
42+
43+
func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) {
44+
commit := new(Commit)
45+
return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s", user, repo, commitID), nil, nil, &commit)
46+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /