Closed pburkholder closed 7 years ago
I have an idea of what the problem is.
remote := "file:///Users/pburkholder/tmp/vcs" // panics
local, _ := ioutil.TempDir("", "go-vcs")
fmt.Println(local)
repo, _ := vcs.NewRepo(remote, local)
// Returns: instance of GitRepo
repo.Vcs()
This last line is line 18 in your snippet which is where the nil panic happens. An error was returned.
vcs.NewRepo
tries to detect the type. It can't detect the type from file:///Users/pburkholder/tmp/vcs
.
There are two options here. First, if you know it's git you can use vcs.NewGitRepo
instead. If you know it's another type there are constructors for those types as well.
If you have a good suggestion on detecting the type from a file path, such as your example, i'd be interested in hearing it or reviewing a pull request.
@sdboyer I'm considering adding auto-detection for file://
paths. How would this impact gps work? Would it be useful?
@mattfarina i don't think it would directly impact, because gps has its own multi-layered logic that receives input paths and decides how to actually source them in.
i do still need to implement analogous logic for this, though, in order to get that mirrors support in. So even if gps doesn't use this directly, i'll do a "little bit of copying" and take advantage of it :)
reflecting a little more, i'm sure it would be possible to write a func that, given a file://
path, figures out the type of repo and returns the appropriate object. if that's what you've got in mind, then i think gps could use that directly.
it might only be useful, though, if it's fully separated from vcs.NewRepo()
. i'd need to make more concrete plans about how gps handles this before i could really say with certainty, though.
@mattfarina is there a way to easily detect the current folder as a remote? It would be great for https://github.com/dnephin/dobi/issues/40
PR in #58. Release coming soon.
Maybe I'm doing it wrong, but I expected something like this to work:
but I get
For a downstream project I'd find it useful to reference repositories by local filesystem paths, so that this package works similarly to:
Thanks, Peter