forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 84
/
main.go
44 lines (37 loc) · 845 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"context"
"fmt"
"os"
"github.com/jenkins-x/go-scm/scm/factory"
"github.com/jenkins-x/go-scm/scm/factory/examples/helpers"
)
func main() {
args := os.Args
if len(args) < 2 {
fmt.Println("usage: repo ref")
os.Exit(1)
return
}
repo := args[1]
ref := "master"
if len(args) > 2 {
ref = args[2]
}
client, err := factory.NewClientFromEnvironment()
if err != nil {
helpers.Fail(err)
return
}
fmt.Printf("finding combined status in repo: %s ref: %s\n", repo, ref)
ctx := context.Background()
results, _, err := client.Repositories.FindCombinedStatus(ctx, repo, ref)
if err != nil {
helpers.Fail(err)
return
}
fmt.Printf("state: %v sha: %s\n", results.State, results.Sha)
for _, s := range results.Statuses {
fmt.Printf("target %s state %v label %s\n", s.Target, s.State, s.Label)
}
}