-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 851 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
package main
import (
"context"
"flag"
"fmt"
"os"
"strings"
"github.com/google/go-github/github"
)
func main() {
var prNumber int
flag.IntVar(&prNumber, "pr-number", 0, "The number of the Agent Pool controller workers.")
flag.Parse()
if prNumber == 0 {
fmt.Println("PR number is not passed")
os.Exit(1)
}
fmt.Println("PR number:", prNumber)
r, ok := os.LookupEnv("GITHUB_REPOSITORY")
if !ok {
fmt.Println("Failed to get the repository via GITHUB_REPOSITORY")
os.Exit(1)
}
rr := strings.Split(r, "/")
client := github.NewClient(nil)
files, _, err := client.PullRequests.ListFiles(context.TODO(), rr[0], rr[1], prNumber, &github.ListOptions{})
if err != nil {
fmt.Println(fmt.Errorf("Failed to get a file list: %s", err.Error()))
os.Exit(1)
}
for _, f := range files {
fmt.Println(*f.Filename, *f.Status)
}
}