initial commit
This commit is contained in:
commit
c215536745
5 changed files with 298 additions and 0 deletions
62
cmd/acb/main.go
Normal file
62
cmd/acb/main.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"o5r.ca/autocrossbow/contributions"
|
||||
"o5r.ca/autocrossbow/issues"
|
||||
)
|
||||
|
||||
func main() {
|
||||
proj := os.Args[1]
|
||||
ghusername := os.Args[2]
|
||||
start := os.Args[3]
|
||||
end := os.Args[4]
|
||||
DoPrs(proj, ghusername, start, end)
|
||||
DoJira(start, end)
|
||||
}
|
||||
|
||||
func DoPrs(proj, ghusername, start, end string) {
|
||||
|
||||
prs, err := contributions.GetPRs(proj, ghusername, start, end)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("error getting PRs: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ghf, err := os.Create(fmt.Sprintf("gh-%s-%s-%s-%s-%d.json", proj, ghusername, start, end, time.Now().Unix()))
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("error creating PR file: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
enc := json.NewEncoder(ghf)
|
||||
err = enc.Encode(prs)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("error writing out PRs: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
func DoJira(start, end string) {
|
||||
host := os.Getenv("JIRA_HOST")
|
||||
user := os.Getenv("JIRA_TARGET_USER")
|
||||
prs, err := issues.GetIssues(host, user, start, end)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("error getting PRs: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ghf, err := os.Create(fmt.Sprintf("jira-%s-%s-%s-%s-%d.json", host, user, start, end, time.Now().Unix()))
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("error creating PR file: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
enc := json.NewEncoder(ghf)
|
||||
err = enc.Encode(prs)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("error writing out PRs: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue