diff --git a/cmd/pkgdashcli/main.go b/cmd/pkgdashcli/main.go index 2b68832..053210e 100644 --- a/cmd/pkgdashcli/main.go +++ b/cmd/pkgdashcli/main.go @@ -38,15 +38,16 @@ var ( ) type Config struct { - PullRequestTitle string `json:"pull_request_title" yaml:"pull_request_title"` - PullRequestBody string `json:"pull_request_body" yaml:"pull_request_body"` + PullRequestTitle string `json:"pull_request_title" yaml:"pull_request_title"` + PullRequestBody string `json:"pull_request_body" yaml:"pull_request_body"` + Branches []string `json:"branches" yaml:"branches"` } var ( configFiles = []string{ "dependabot.yml", - "pkgdash.yml", - "pkgdash.yaml", + "pkgdashcli.yml", + "pkgdashcli.yaml", } configDirs = []string{ ".gitea", @@ -158,10 +159,11 @@ func main() { logger.Fatalf(ctx, "failed to get repo management") } - branch := os.Getenv("GITHUB_REF_NAME") switch repoMgmt { case "gitea": - err = giteaPullRequest(ctx, cfg, branch, mvs) + for _, branch := range cfg.Branches { + err = giteaPullRequest(ctx, cfg, branch, mvs) + } } if err != nil { @@ -224,9 +226,25 @@ func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[ logger.Fatalf(ctx, "failed to fetch repo: %v", err) } - headRef, err := repo.Head() + var headRef *plumbing.Reference + refIter, err := repo.Branches() if err != nil { - logger.Fatalf(ctx, "failed to get repo head: %v", err) + logger.Fatalf(ctx, "failed to get branches: %v", err) + } + for { + ref, err := refIter.Next() + if err != nil { + break + } + if ref.Name().String() == branch { + headRef = ref + break + } + } + refIter.Close() + + if headRef == nil { + logger.Fatalf(ctx, "failed to get repo branch head") } logger.Infof(ctx, "repo head %s", headRef)