Skip to content

fix repo create in org with license/ignore#3924

Merged
vilmibm merged 3 commits intotrunkfrom
rest-org-repo-bug
Jun 30, 2021
Merged

fix repo create in org with license/ignore#3924
vilmibm merged 3 commits intotrunkfrom
rest-org-repo-bug

Conversation

@vilmibm
Copy link
Contributor

@vilmibm vilmibm commented Jun 30, 2021

Fixes #3918

This PR detects when a gh repo create foo/bar invocation targets an org and the user selects a .gitignore/license. In that case we switch to REST, but we have to either pick the user or org version of the REST endpoint.

In order to support passing visibility when using the create org repo endpoint, we need to opt into the nebula preview.

@vilmibm vilmibm requested a review from samcoe June 30, 2021 22:44
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks for taking on this work 🙇. I left one non-blocking question.

}

if input.GitIgnoreTemplate != "" || input.LicenseTemplate != "" {
input.Visibility = strings.ToLower(input.Visibility)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦


path := "user/repos"
if isOrg {
path = fmt.Sprintf("orgs/%s/repos", ownerName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure the answer is no, but can we just use the input.OwnerID here? Seems silly that the API couldn't resolve that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's a graphql node ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but your confusion is warranted! it starts out life as an owner string and is then updated in place to be a node ID.

@vilmibm vilmibm merged commit a6710ec into trunk Jun 30, 2021
// using API v3 here because the equivalent in GraphQL needs `read:org` scope
func resolveOrganization(client *api.Client, hostname, orgName string) (string, error) {
func resolveOrganization(client *api.Client, hostname, orgName string) (string, bool, error) {
var response struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// using API v3 here because the equivalent in GraphQL needs `read:org` scope
func resolveOrganization(client *api.Client, hostname, orgName string) (string, error) {
func resolveOrganization(client *api.Client, hostname, orgName string) (string, bool, error) {
var response struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whooooo

@anon-gif anon-gif mentioned this pull request Jul 6, 2021
Copy link

@ahme0008 ahme0008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samcoe samcoe deleted the rest-org-repo-bug branch July 13, 2021 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh repo create does not respect organization name when instantiating repo

4 participants