pksunkara / octonode

github api v3 in nodejs
MIT License
1.19k stars 237 forks source link

archive not working with redirect #328

Closed DrNiels closed 5 years ago

DrNiels commented 5 years ago

When I access a repository that has moved via

let ghrepo = client.repo(repo);
ghrepo.archive('zipball',commit, (error, data, headers) => { ... });

I receive an error:

    Error: Repo archive error
    at /var/task/node_modules/octonode/lib/octonode/repo.js:637:21
    at Client.errorHandle (/var/task/node_modules/octonode/lib/octonode/client.js:249:14)
    at Request._callback (/var/task/node_modules/octonode/lib/octonode/client.js:280:24)
    at Request.self.callback (/var/task/node_modules/request/request.js:185:22)

Since accessing a download link of a repository that has moved via HTML works fine, I'd expect it to work in this case as well. Other functionality like getting a list of commits via octonode works fine as well. I'm using the current 0.9.5 from npm. Changing the repository address to the new location works fine and allows a proper download.

Do I need to update the call somehow or is it a bug?

Thanks a lot!

pksunkara commented 5 years ago

I think you should change the repository name given to client.repo

DrNiels commented 5 years ago

I do not necessarily know that the repository was moved, so it would be nice if it was possible. In addition, "Repo archive error" does not sound like a specific error for a moved repository and I would like to avoid some generic error to the user if he moved his repository and now needs to find out by himself what's wrong.