Skip to content

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

+9
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

+7
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)