diff --git a/cmd/root.go b/cmd/root.go index 141fd3e6..a6ce8320 100755 --- a/cmd/root.go +++ b/cmd/root.go @@ -26,7 +26,7 @@ var RootCmd = &cobra.Command{ func init() { RootCmd.PersistentFlags().StringP("gh-base-url", "g", "", "Base URL of the (v3) GitHub API, needs to be changed if GitHub enterprise is used.") RootCmd.PersistentFlags().StringP("token", "T", "", "The GitHub personal access token. Can also be set using the GITHUB_TOKEN environment variable.") - RootCmd.PersistentFlags().StringP("log-level", "L", "info", "The level of logging that should be made. Available values: debug, info, error") + RootCmd.PersistentFlags().StringP("log-level", "L", "info", "The level of logging that should be made. Available values: trace, debug, info, error") RootCmd.AddCommand(RunCmd) RootCmd.AddCommand(StatusCmd) diff --git a/internal/git/git.go b/internal/git/git.go index c40bfc18..4d229647 100755 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -18,7 +18,7 @@ type Git struct { Token string } -// Clone clones a repository +// Clone a repository func (g Git) Clone() error { u, err := url.Parse(g.Repo) if err != nil { @@ -52,7 +52,7 @@ func (g Git) Clone() error { return err } -// Commit commits and pushes changes +// Commit and push if any changes has been made to the directory func (g Git) Commit(commitMessage string) error { r, err := git.PlainOpen(g.Directory) if err != nil { diff --git a/internal/github/github.go b/internal/github/github.go index f54a1cc9..5a281e48 100755 --- a/internal/github/github.go +++ b/internal/github/github.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/google/go-github/v32/github" + log "github.com/sirupsen/logrus" "golang.org/x/oauth2" "github.com/lindell/multi-gitter/internal/domain" @@ -89,7 +90,6 @@ func (g Github) getRepositories(ctx context.Context, orgName string, page int) ( // CreatePullRequest creates a pull request func (g Github) CreatePullRequest(ctx context.Context, repository domain.Repository, newPR domain.NewPullRequest) error { - pr, err := g.createPullRequest(ctx, repository, newPR) if err != nil { return err @@ -152,6 +152,8 @@ func (g Github) GetPullRequestStatuses(ctx context.Context, orgName, branchName prStatuses := []domain.PullRequest{} for _, r := range repos { + log := log.WithField("repo", fmt.Sprintf("%s/%s", r.GetOwner().GetLogin(), r.GetName())) + log.Debug("Fetching latest pull request") prs, _, err := g.ghClient.PullRequests.List(ctx, orgName, r.GetName(), &github.PullRequestListOptions{ Head: fmt.Sprintf("%s:%s", orgName, branchName), State: "all", @@ -175,6 +177,7 @@ func (g Github) GetPullRequestStatuses(ctx context.Context, orgName, branchName } else if pr.ClosedAt != nil { status = domain.PullRequestStatusClosed } else { + log.Debug("Fetching the combined status of the pull request") combinedStatus, _, err := g.ghClient.Repositories.GetCombinedStatus(ctx, orgName, r.GetName(), pr.GetHead().GetSHA(), nil) if err != nil { return nil, err