sourcegraph / srclib

srclib is a polyglot code analysis library, built for hackability. It consists of language analysis toolchains (currently for Go and Java, with Python, JavaScript, and Ruby in beta) with a common output format, and a CLI tool for running the analysis.
https://srclib.org
Other
942 stars 62 forks source link

getVCSCloneURL has hard dependency on Git remote 'origin' #27

Open jashank opened 10 years ago

jashank commented 10 years ago

getVCSCloneURL is hardwired to require a Git remote called origin, and the error passed back up to (e.g.) src config is not especially helpful.

> src config --subdir=.        
2014/08/15 12:51:03 could not get VCS URL: exit status 1
2014/08/15 12:51:03 could not get VCS URL: exit status 1
2014/08/15 12:51:03 could not get VCS URL: exit status 1
2014/08/15 12:51:03 could not get VCS URL: exit status 1
Running: [/home/jashank/.srclib/sourcegraph.com/sourcegraph/srclib-go/.bin/srclib-go scan --repo  --subdir .]
  --> with input {}
warning: "./..." matched no packages
Running: [/home/jashank/.srclib/sourcegraph.com/sourcegraph/srclib-javascript/.bin/srclib-javascript scan-commonjs --repo  --subdir .]
  --> with input {}
Running: [/home/jashank/.srclib/sourcegraph.com/sourcegraph/srclib-ruby/.bin/srclib-ruby scan --repo  --subdir .]
  --> with input {}
failed to open repo: could not get VCS URL: exit status 1

In reality, what's happening here is the command git config remote.origin.url, which returns $?=1 if that key doesn't exist.

Specifying --subdir is necessary for the same reason; without it, I get:

> src config
2014/08/15 12:53:20 could not get VCS URL: exit status 1
2014/08/15 12:53:20 could not get VCS URL: exit status 1
2014/08/15 12:53:20 could not get VCS URL: exit status 1
2014/08/15 12:53:20 could not get VCS URL: exit status 1
Configuration is currently only supported at the root (top-level directory) of a repository, not in a subdirectory ("").
sqs commented 10 years ago

Yes, this is messy. As a temporary workaround, can you just make a remote named origin? I will

soon.

Thanks for reporting this.

sqs commented 10 years ago

FYI, I made a change that affects (but does not yet fix this).

https://github.com/sourcegraph/srclib/commit/737e0ed8a9ea48d2262db73bb8af4a229706c888