node-gh / gh

(DEPRECATED) GitHub CLI made with NodeJS. Use the official https://cli.github.com/ instead.
http://nodegh.io
Other
1.71k stars 217 forks source link

Redirects are not followed #579

Open jayhogan opened 6 years ago

jayhogan commented 6 years ago

Version: gh 1.13.5

My first experience using gh was working with a repo that I recently renamed. In this scenario, github will respond with a 301 and include the new url in the Location header field.

Here is a sample response:

{
    message: 'Moved Permanently',
    url: 'https://api.github.com/repositories/119537897/issues?state=open&labels=&access_token=xx',
    documentation_url: 'https://developer.github.com/v3/#http-redirects',
    meta: { 
       'x-ratelimit-limit': '5000',
       'x-ratelimit-remaining': '4941',
       'x-ratelimit-reset': '1539339189',
       'x-oauth-scopes': 'user, public_repo, repo, repo:status, delete_repo, gist',
       location: 'https://api.github.com/repositories/119537897/issues?state=open&labels=&access_token=xx',
       status: '301 Moved Permanently'
    }
}

Relevant github API docs: https://developer.github.com/v3/#http-redirects

I resolved the issue by updating the remote url in my local repo:

git remote set-url origin https://github.com/myOrg/my-new-repo-name.git
protoEvangelion commented 6 years ago

@jayhogan Thanks for reporting!

Were you noticing this in previous versions?

Also what cmd(s) were you running when you ran into this?

jayhogan commented 6 years ago

Sorry for the late response. This was my first experience with node-gh so I have not tried previous versions of the tool. I encountered the problem with gh issue and gh pr but I would expect to see this issue with any command in a renamed repo.

There is a simple workaround (update your remote reference!) so I would consider this a low priority issue.

Thanks!

protoEvangelion commented 6 years ago

Thanks for expanding on that @jayhogan. It's definitely something we should do!