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 fails on a Repo that was moved or renamed #345

Closed
daltonmatos opened this issue Feb 10, 2020 · 6 comments
Closed

gh fails on a Repo that was moved or renamed #345

daltonmatos opened this issue Feb 10, 2020 · 6 comments

Comments

@daltonmatos
Copy link

daltonmatos commented Feb 10, 2020

Describe the bug

I have a repository that was moved from one organization to another. The remote origin was still pointing to the old org, which works transparently when pushing and pulling code.

gh fails recognize that the repository has moved.

gh version 0.5.4 (2020-02-10)
https://github.com/cli/cli/releases/tag/v0.5.4

Steps to reproduce the behavior

  1. Create and clone a repo
  2. Move this repo to another org (or github profile)
  3. run gh pr list on this cloned code (cloned before the move)
  4. See the error: graphql error: 'Could not resolve to a Repository with the name '<repo-name>'.'

Expected vs actual behavior

Expected the PR to be listed.

Logs

Here is an example of this behavior. After changing the remote URL gh worked.

> gh pr list

Pull requests for b2w-bit/async-worker

graphql error: 'Could not resolve to a Repository with the name 'async-worker'.'

>  git remote -v
origin	github.com:b2w-bit/async-worker (fetch)
origin	github.com:b2w-bit/async-worker (push)

> git remote set-url origin github.com:b2wdigital/async-worker

 > gh pr list                                                  

Pull requests for b2wdigital/async-worker

#151  Generate HTML Docs             feature/new-docs-html-generated
#150  Feature/sphinx docs structure  feature/sphinx-docs-structure

@vilmibm vilmibm added bug Something isn't working p2 Affects more than a few users but doesn't prevent core functions labels Feb 10, 2020
@mgattozzi
Copy link

This exact same behavior also occurs for repos that were renamed.

@tierninho tierninho changed the title gh fails on a Repo that was moved gh fails on a Repo that was moved or renamed Feb 10, 2020
@tierninho
Copy link
Contributor

  1. I tested the repo move bug and I could not reproduce this. Note: my repo and org were public and both mine, if it matters.

Here are my logs while testing on v0.5.4:

➜  tests git:(master) ✗ git clone https://github.com/tierninho/sdsdsdffsd

➜  tests git:(master) ✗ cd sdsdsdffsd

➜  sdsdsdffsd git:(master) gh pr list

Pull requests for tierninho/sdsdsdffsd

#1  sdfsdf  tierninho-patch-1

➜  sdsdsdffsd git:(master) gh issue list

Issues for tierninho/sdsdsdffsd

#2  sdfsd

➜  sdsdsdffsd git:(master) git remote -v
origin	https://github.com/tierninho/sdsdsdffsd (fetch)
origin	https://github.com/tierninho/sdsdsdffsd (push)

➜  sdsdsdffsd git:(master) gh pr list

Pull requests for tierninho/sdsdsdffsd

#1  sdfsdf  tierninho-patch-1

➜  sdsdsdffsd git:(master) gh issue list

Issues for tierninho/sdsdsdffsd

#2  sdfsd

➜  sdsdsdffsd git:(master) git remote -v
origin	https://github.com/tierninho/sdsdsdffsd (fetch)
origin	https://github.com/tierninho/sdsdsdffsd (push)

I could also verify the data in the newly transferred repo once I cd into that direcotry. Should we even be allowing access to data in the "old" repo if it is transferred to another org?


  1. As for the renamed repo, I had no issues either and my logs were similar.

@daltonmatos
Copy link
Author

In fact, now seeing yout check I also created a new repo and did these checks:

  1. Renamed the repo;
  2. Transfered ownership to another org

gh worked in every step, even using the original remote url.

But still, I have this repo (https://github.com/b2wdigital/async-worker) that used to belong to b2w-bit org (https://github.com/B2W-BIT) and now belongs to b2wdigital org (https://github.com/b2wdigital). If I point the remote to the old org gh fails. If I change to the new gh works. Don't know why.

The only difference is that when we changed this project from one org to the other we didn't transfered ownership we renamed the whole org.

I will try do do more checks to see if I can find anything.

@daltonmatos
Copy link
Author

With a fresh new clone I was able to reproduce the problem. Note: I cloned the project using the old URL.

> git clone github.com:b2w-bit/async-worker          
Cloning into 'async-worker'...
remote: Enumerating objects: 315, done.
remote: Counting objects: 100% (315/315), done.
remote: Compressing objects: 100% (182/182), done.
remote: Total 5102 (delta 165), reused 249 (delta 119), pack-reused 4787
Receiving objects: 100% (5102/5102), 2.36 MiB | 3.40 MiB/s, done.
Resolving deltas: 100% (3332/3332), done.

> cd async-worker
> gh pr list                               

Pull requests for b2w-bit/async-worker

graphql error: 'Could not resolve to a Repository with the name 'async-worker'.'

> git remote -v
origin	github.com:b2w-bit/async-worker (fetch)
origin	github.com:b2w-bit/async-worker (push)

> git remote set-url origin github.com:b2wdigital/async-worker
> gh pr list                                                  

Pull requests for b2wdigital/async-worker

#154  Enabling new parameters from aioamqp     dmvieira:feature/adding-new-parameters-from-aioamqp
#153  Adding code of conduct and contributing  dmvieira:feature/contributing
#151  Generate HTML Docs                       feature/new-docs-html-generated
#150  Feature/sphinx docs structure            feature/sphinx-docs-structure

Maybe this could be a good starting point to debug the code. The project is public so if anyone could try this too.

Note: The same behavior happens when clonning via https.

Thanks,

@tierninho tierninho removed bug Something isn't working p2 Affects more than a few users but doesn't prevent core functions labels Feb 11, 2020
@tierninho
Copy link
Contributor

@daltonmatos thanks for the update on this. I can reproduce this, however I believe the results are expected and this is not a bug.

Anytime you rename an org means you have to update your local repos to the new location, as outlined in the warning ahead of making the change:

Screen Shot 2020-02-11 at 8 56 10 AM

I could not break the flow until I decided to rename the org.

Steps were:

  • Clone repo under an org
  • Verify gh issue list works
  • Rename Org on Github.com
  • Verify gh issue list errors out (as expected)
  • Update remote in terminal
  • Verify gh issue list works

Happy to look into this further. Until then removing the bug label and closing the issue.

@daltonmatos
Copy link
Author

Sure. Thanks.

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

No branches or pull requests

4 participants