guyzmo / git-repo

Git-Repo: CLI utility to manage git services from your workspace
https://webchat.freenode.net/?channels=#git-repo
Other
842 stars 85 forks source link

Hard coded remote names #141

Closed jayvdb closed 7 years ago

jayvdb commented 7 years ago

I've only started playing, and it seems like the remote 'gitlab' is special, and everything else is ignored. I suspect the same occurs for github and others.

This means git-repo cant be immediately used in a git clone of a gitlab repo that was cloned using git clone, as that will use the remote name origin.

It would be nice if git-repo handled a missing gitlab remote by looking for another suitable remote that points to gitlab, with a sensible strategy that works in most cases.

The most obvious fallback is to look to see if origin is a gitlab repo, and use that.

Then looking at all remotes, and see if there is only one that points to gitlab, then that should be the default used.

git-repo could then create a gitlab remote if it needs to avoid expensive calls again, so the gitlab remote becomes more of a cached default remote, rather than the only one that works.

guyzmo commented 7 years ago

That would be an amazing nice to have feature, indeed! And I'm totally open for getting a PR to get something doing that implemented.

I believe that could be done with a command like:

% git lab add
I found several remotes pointing to gitlab.com:
[1] origin: git@gitlab.com:foo/bar
[2] other: https://gitlab.com:bar/foo
[3] yayay: git@gitlab.com:bleh/blih
Please chose which remote shall the gitlab one point to: _

because I'd rather avoid doing it automagically whenever you call any command (when I call git lab request ls I don't expect anything to get mutated), but rather have the command fail:

% git lab request ls
Failure: repository not configured.
Hint: there's at least one existing remote pointing to gitlab.com, to make it work, type git lab add!

And anyway, until it's done, you can easily add the gitlab remote when it's missing with:

% git lab add user/repo

Currently, I first want to get the basic features well covered, and the existing one to work well. So I'm not scheduling it into a milestone.

guyzmo commented 7 years ago

I've pushed git lab add and git lab upstream in the devel branch. It will be in 1.10 🙌