Skip to content

Commit

Permalink
Catch merge breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
samcoe committed Jun 21, 2022
1 parent 055052a commit f50a0ae
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (err HTTPError) ScopesSuggestion() string {
func (c Client) GraphQL(hostname string, query string, variables map[string]interface{}, data interface{}) error {
// AuthToken is being handled by Transport, so let go-gh know that it does not need to resolve it.
opts := ghAPI.ClientOptions{Host: hostname, AuthToken: "none", Transport: c.http.Transport}
opts.Headers = map[string]string{"GraphQL-Features": "merge_queue"}
gqlClient, err := gh.GQLClient(&opts)
if err != nil {
return err
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/pr/shared/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sort"
"strconv"
"strings"
"time"

"github.com/cli/cli/v2/api"
remotes "github.com/cli/cli/v2/context"
Expand Down Expand Up @@ -141,7 +142,8 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
fields.Add("id") // for additional preload queries below

if fields.Contains("isInMergeQueue") || fields.Contains("isMergeQueueEnabled") {
detector := fd.NewDetector(httpClient, f.repo.RepoHost())
cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
detector := fd.NewDetector(cachedClient, f.repo.RepoHost())
prFeatures, err := detector.PullRequestFeatures()
if err != nil {
return nil, nil, err
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/repo/edit/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"net/http"
"strings"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/MakeNowJust/heredoc"
Expand Down Expand Up @@ -162,7 +163,8 @@ func editRun(ctx context.Context, opts *EditOptions) error {
if opts.InteractiveMode {
detector := opts.Detector
if detector == nil {
detector = fd.NewDetector(opts.HTTPClient, repo.RepoHost())
cachedClient := api.NewCachedHTTPClient(opts.HTTPClient, time.Hour*24)
detector = fd.NewDetector(cachedClient, repo.RepoHost())
}
repoFeatures, err := detector.RepositoryFeatures()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/repo/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func listRun(opts *ListOptions) error {
}

if opts.Detector == nil {
opts.Detector = fd.NewDetector(httpClient, host)
cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
opts.Detector = fd.NewDetector(cachedClient, host)
}
features, err := opts.Detector.RepositoryFeatures()
if err != nil {
Expand Down

0 comments on commit f50a0ae

Please sign in to comment.