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 1cd0db3

Browse files
committed
repo_commit: add GetReferenceSHA
1 parent 61758ab commit 1cd0db3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎media_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
const (
8+
MediaApplicationSHA = "application/vnd.gogs.sha"
9+
)

‎repo_commit.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package gogs
66

77
import (
88
"fmt"
9+
"net/http"
910
)
1011

1112
// CommitMeta contains meta information of a commit in terms of API.
@@ -44,3 +45,9 @@ func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) {
4445
commit := new(Commit)
4546
return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s", user, repo, commitID), nil, nil, &commit)
4647
}
48+
49+
func (c *Client) GetReferenceSHA(user, repo, ref string) (string, error) {
50+
data, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s", user, repo, ref),
51+
http.Header{"Accept": []string{MediaApplicationSHA}}, nil)
52+
return string(data), err
53+
}

0 commit comments

Comments
(0)

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