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

gh repo create --repo org/repo creates owner/repo #702

Open
thisguychris opened this issue Mar 26, 2020 · 12 comments
Open

gh repo create --repo org/repo creates owner/repo #702

thisguychris opened this issue Mar 26, 2020 · 12 comments
Labels

Comments

@thisguychris
Copy link

@thisguychris thisguychris commented Mar 26, 2020

Describe the bug

Hi @mislav! Thank you for creating this. I'm trying to create the new repo via CLI, and it seems --repo is not passing the owner/repo format? It just defaults to owner/folder-name

In fact, I try to create a new repo using a different name it says repository already exists.
gh version 0.6.2 (2020-03-18)

Steps to reproduce the behavior

  1. Go to folder reponame
  2. gh create repo --repo org/reponame
  3. it creates owner/reponame instead

Expected vs actual behavior

It should create a repo name under the org.

Logs

Doing it twice says:
graphql error: 'Name already exists on this account'

Even though there's no repo name under the org, only the local repo under my own account.

@thisguychris thisguychris added the bug label Mar 26, 2020
@thisguychris thisguychris changed the title gh repo create --repo org/repo creates local repo gh repo create --repo org/repo creates owner/repo Mar 26, 2020
@mislav
Copy link
Member

@mislav mislav commented Mar 26, 2020

Hi @mislav! Thank you for creating this.

You're welcome! It's not just me— we have a whole team! 🎉

2. gh create repo --repo org/reponame

I can see how this can be confusing. The global --repo flag usually selects another repository to read information from, but for the gh repo create command it's not really applicable. (We tried to hide the flag here, but our CLI framework doesn't make that possible in an easy way.) The correct invocation in this instance would be:

gh repo create ORG/REPONAME

Can you try that and see if it works? And how could we improve the docs so the usage syntax of gh repo create would be more immediately apparent?

@thisguychris
Copy link
Author

@thisguychris thisguychris commented Mar 26, 2020

Hey @mislav and team! Thank you for making this cli!


So I've tried your command, it indeed creates org/repo.

I'm not sure if this is a bug, but if I added --repo flag it creates owner/repo.
Would you mind showing me an example of the usage of the global flag --repo usage?

Because if I --help this command:
gh repo create --help

It shows an option to use the global flag, if it's not applicable should we show it in help?

@mislav mislav added the docs label Mar 26, 2020
@mislav
Copy link
Member

@mislav mislav commented Mar 26, 2020

Would you mind showing me an example of the usage of the global flag --repo usage?

For example:

gh pr list  #=> queries PRs in the current repository
gh pr list --repo cli/cli  #=> queries PRs in the cli/cli repository

Because if I --help this command […] It shows an option to use the global flag, if it's not applicable should we show it in help?

Exactly: we shouldn't show the flag here. The --repo flag makes sense in most other commands, but not repo create. The reason it's shown here is because it's a "global" flag (i.e. ideally supposed to be applicable across all gh commands), but we should try to hide it here.

@thisguychris
Copy link
Author

@thisguychris thisguychris commented Mar 26, 2020

okay understood @mislav feel free to close this issue, or just reference it to hide the global command, it's clear to me now. 👌 Again awesome tool! 🙌 I've been a user since the hub days, and I've read the blog, talk about a blast in the past! I didn't realize it was in ruby before.

Stay healthy!

@xloem
Copy link

@xloem xloem commented Apr 9, 2020

Is there similarly a way to fork a repo into an organization, instead of a user?

@computermusik
Copy link

@computermusik computermusik commented Apr 12, 2020

I have the same/similar issue. My owner is computermusik and I have an organisation called Quintet-net. The command "gh repo create Quintet-net/Sirenen" creates computermusik/Sirenen not Quintet-net/Sirenen. What am I missing here?

@mislav
Copy link
Member

@mislav mislav commented Apr 13, 2020

Is there similarly a way to fork a repo into an organization

@xloem There is currently no way to fork into an organization.

The command "gh repo create Quintet-net/Sirenen" creates computermusik/Sirenen not Quintet-net/Sirenen

@computermusik That is indeed strange; your gh repo create should have definitely created the repository under the Quintet-net org. You can enable verbose logging with DEBUG=api gh repo create ... to try and spot something that seems off. Please report this and whatever else you find in a separate issue.

@computermusik
Copy link

@computermusik computermusik commented Apr 13, 2020

@mislav
Copy link
Member

@mislav mislav commented Apr 13, 2020

I'm asking because I get an error when entering this line: DEBUG=api: Command not found.

Sorry, the DEBUG=api gh ... syntax only works in shells such as bash, zsh, fish. If you are in a different shell, such as PowerShell on Windows, the syntax to set and export an environment variable might be different. Please consult the documentation for your shell!

@computermusik
Copy link

@computermusik computermusik commented Apr 13, 2020

@mislav
Copy link
Member

@mislav mislav commented Apr 14, 2020

Alright, it worked in bash.

Thanks for trying! Are you saying that gh repo create Quintet-net/Sirenen did the right thing in bash (creating an org repo), but produced the wrong result (created a personal repo) in a different shell? If so, then this smells like a bug and we would appreciate knowing about the specifics so we can track it down and fix it for your shell.

What's a little irritating is that it states on the bottom:
fatal: remote origin already exists.
exit status 128

What I think happened is that you ran gh repo create from the current directory where there is already a git repository, and in that case gh repo create assumes that you are creating a GitHub repository where you intend to push the code from your local git repository and tries to add it as "origin" remote, but you already have that remote.

What do you think would be better behavior?

@computermusik
Copy link

@computermusik computermusik commented Apr 15, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.