-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cli#178 from github/issues-disabled
Warn about repo issues disabled on `issue status/list/create`
- Loading branch information
Showing
7 changed files
with
165 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
package api | ||
|
||
import "fmt" | ||
import ( | ||
"fmt" | ||
|
||
func GitHubRepoId(client *Client, ghRepo Repo) (string, error) { | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// Repository contains information about a GitHub repo | ||
type Repository struct { | ||
ID string | ||
HasIssuesEnabled bool | ||
} | ||
|
||
// GitHubRepo looks up the node ID of a named repository | ||
func GitHubRepo(client *Client, ghRepo Repo) (*Repository, error) { | ||
owner := ghRepo.RepoOwner() | ||
repo := ghRepo.RepoName() | ||
|
||
query := ` | ||
query FindRepoID($owner:String!, $name:String!) { | ||
repository(owner:$owner, name:$name) { | ||
id | ||
} | ||
query($owner: String!, $name: String!) { | ||
repository(owner: $owner, name: $name) { | ||
id | ||
hasIssuesEnabled | ||
} | ||
}` | ||
variables := map[string]interface{}{ | ||
"owner": owner, | ||
"name": repo, | ||
} | ||
|
||
result := struct { | ||
Repository struct { | ||
Id string | ||
} | ||
Repository Repository | ||
}{} | ||
err := client.GraphQL(query, variables, &result) | ||
if err != nil || result.Repository.Id == "" { | ||
return "", fmt.Errorf("failed to determine GH repo ID: %s", err) | ||
|
||
if err != nil || result.Repository.ID == "" { | ||
newErr := fmt.Errorf("failed to determine repository ID for '%s/%s'", owner, repo) | ||
if err != nil { | ||
newErr = errors.Wrap(err, newErr.Error()) | ||
} | ||
return nil, newErr | ||
} | ||
|
||
return result.Repository.Id, nil | ||
return &result.Repository, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"data": { | ||
"repository": { | ||
"hasIssuesEnabled": true, | ||
"issues": { | ||
"nodes": [ | ||
{ | ||
|
Oops, something went wrong.