sifive / wit

Workspace Integration Tool
Apache License 2.0
23 stars 13 forks source link

Error out gracefully when failing to clone a dependency #253

Closed mmjconolly closed 4 years ago

mmjconolly commented 4 years ago

This addresses the case where a package's dependency is unable to be cloned, but where it would still attempt to checkout a revision. The message looked like

File "/usr/local/lib/python3.8/site-packages/wit/package.py", line 133, in checkout
    current_origin = self.repo.get_remote()
AttributeError: 'NoneType' object has no attribute 'get_remote'

This now returns errors after the parallel clone more eagerly Error now looks like:

Creating new workspace [/home/user/workspace]
Cloned product1
The workspace now depends on 'product1::abcd123'
Cloned foo

--- ERROR ---
Bad remote for 'baa':
  git@github.com:sifive/baa
mmjconolly commented 4 years ago

LGTM!

I wish there were a clean way for us to augment the underlying Git message, since it's really not clear that Bad remote sometimes means "Permission denied", but I'm not sure if it'd be a good idea to try to match on the strings Git prints out. I suppose that something like this would be cleaner with a lower-level API like libgit2?

I think github actually 404s for a permission denied, so that they don't leak the existence of things

richardxia commented 4 years ago

I think github actually 404s for a permission denied, so that they don't leak the existence of things

Right, but even if that's the case, we could offer a suggestion or two to the user on how to address it, e.g. "Do you have permissions to this repo, or did you misspell the repo?". My main concern with string matching on "Bad remote" is that it could be dependent on the version of underneath or even locale settings, if Git supports that.

mmjconolly commented 4 years ago

I think github actually 404s for a permission denied, so that they don't leak the existence of things

Right, but even if that's the case, we could offer a suggestion or two to the user on how to address it, e.g. "Do you have permissions to this repo, or did you misspell the repo?". My main concern with string matching on "Bad remote" is that it could be dependent on the version of underneath or even locale settings, if Git supports that.

Ah I see what you mean, yeah libgit2 would help with that