github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/release/github/commits.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package github 5 6 import "fmt" 7 8 // Commit defines a git commit on Github 9 type Commit struct { 10 SHA string `json:"sha"` 11 } 12 13 const ( 14 commitListPath = "/repos/%s/%s/commits" 15 ) 16 17 // Commits lists commits from Github repo 18 func Commits(user, repo, token string) ([]Commit, error) { 19 url, err := githubURL(githubAPIURL) 20 if err != nil { 21 return nil, err 22 } 23 url.Path = fmt.Sprintf(commitListPath, user, repo) 24 var commits []Commit 25 if err = Get(token, url.String(), &commits); err != nil { 26 return nil, err 27 } 28 return commits, nil 29 }