Add feature detection query
This commit is contained in:
parent
6f0bf82696
commit
76d975524e
2 changed files with 32 additions and 0 deletions
|
|
@ -132,6 +132,28 @@ func ListLinkedBranches(client *Client, repo ghrepo.Interface, issueNumber int)
|
|||
|
||||
}
|
||||
|
||||
// introspects the schema to see if we expose the LinkedBranch type
|
||||
func CheckLinkedBranchFeature(client *Client, host string) (err error) {
|
||||
var featureDetection struct {
|
||||
Name struct {
|
||||
Fields []struct {
|
||||
Name string
|
||||
}
|
||||
} `graphql:"LinkedBranch: __type(name: \"LinkedBranch\")"`
|
||||
}
|
||||
|
||||
err = client.Query(host, "LinkedBranch_fields", &featureDetection, nil)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(featureDetection.Name.Fields) == 0 {
|
||||
return fmt.Errorf("the `gh issue develop` command is not currently available")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// This fetches the oids for the repo's default branch (`main`, etc) and the name the user might have provided in one shot.
|
||||
func FindBaseOid(client *Client, repo *Repository, ref string) (string, string, error) {
|
||||
query := `
|
||||
|
|
|
|||
|
|
@ -84,6 +84,11 @@ func developRunCreate(opts *DevelopOptions) (err error) {
|
|||
}
|
||||
|
||||
opts.IO.StartProgressIndicator()
|
||||
err = api.CheckLinkedBranchFeature(apiClient, baseRepo.RepoHost())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
repo, err := api.GitHubRepo(apiClient, baseRepo)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -190,6 +195,11 @@ func developRunList(opts *DevelopOptions) (err error) {
|
|||
}
|
||||
|
||||
opts.IO.StartProgressIndicator()
|
||||
|
||||
err = api.CheckLinkedBranchFeature(apiClient, baseRepo.RepoHost())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
issueNumber, issueRepo, err := issueMetadata(opts.IssueSelector, opts.IssueRepoSelector, baseRepo)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue