Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not write messages from UpdatePullRequestState #284

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions internal/actions/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,6 @@ func UpdatePullRequestState(
repoMeta := tx.Repository()
branch, _ := tx.Branch(branchName)

_, _ = fmt.Fprint(os.Stderr,
" - fetching latest pull request information for ", colors.UserInput(branchName),
"\n",
)
page, err := client.GetPullRequests(ctx, gh.GetPullRequestsInput{
Owner: repoMeta.Owner,
Repo: repoMeta.Name,
Expand Down Expand Up @@ -625,11 +621,6 @@ func UpdatePullRequestState(
var newPull *gh.PullRequest
if openPull != nil {
if oldId != openPull.ID {
_, _ = fmt.Fprint(os.Stderr,
" - found new pull request for ", colors.UserInput(branchName),
": ", colors.UserInput(openPull.Permalink),
"\n",
)
changed = true
}
branch.PullRequest = &meta.PullRequest{
Expand All @@ -652,12 +643,6 @@ func UpdatePullRequestState(
} else {
// openPull and currentPull is nil
if branch.PullRequest != nil {
_, _ = fmt.Fprint(os.Stderr,
" - ", colors.Failure("ERROR:"),
" pull request for ", colors.UserInput(branchName),
" could not be found on GitHub: ", colors.UserInput(branch.PullRequest.Permalink),
" (removing reference from local state)\n",
)
changed = true
}
branch.PullRequest = nil
Expand Down
26 changes: 24 additions & 2 deletions internal/actions/sync_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,37 @@ func SyncBranch(
if err != nil {
return nil, err
}
fmt.Fprint(os.Stderr,
" - fetching latest pull request information for ", colors.UserInput(branch.Name),
"\n",
)
update, err := UpdatePullRequestState(ctx, client, tx, branch.Name)
if err != nil {
_, _ = fmt.Fprint(os.Stderr, colors.Failure(" - error: ", err.Error()), "\n")
return nil, errors.Wrap(err, "failed to fetch latest PR info")
}
pull = update.Pull
if update.Changed {
_, _ = fmt.Fprint(os.Stderr, " - found updated pull request: ", colors.UserInput(update.Pull.Permalink), "\n")
if update.Pull == nil && branch.PullRequest != nil {
fmt.Fprint(os.Stderr,
" - ", colors.Failure("ERROR:"),
" pull request for ", colors.UserInput(branch.Name),
" could not be found on GitHub: ", colors.UserInput(branch.PullRequest.Permalink),
" (removing reference from local state)\n",
)
} else if update.Pull != nil && branch.PullRequest == nil {
fmt.Fprint(os.Stderr,
" - found new pull request for ", colors.UserInput(branch.Name),
": ", colors.UserInput(update.Pull.Permalink),
"\n",
)
} else if update.Pull != nil && branch.PullRequest != nil && branch.PullRequest.ID != update.Pull.ID {
fmt.Fprint(os.Stderr,
" - found updated pull request: ", colors.UserInput(update.Pull.Permalink),
"\n",
)
}
}
pull = update.Pull
branch, _ = tx.Branch(opts.Branch)
if branch.PullRequest == nil {
_, _ = fmt.Fprint(os.Stderr,
Expand Down