GitHubinator icon indicating copy to clipboard operation
GitHubinator copied to clipboard

multiple, different, remotes can break detection

Open Fryguy opened this issue 7 years ago • 1 comments

In my .git/config, I have remotes that point to both github as well as a private gitlab instance. I've found that depending on the order of the remotes in the .git/config file, the first one listed is the one chosen, and it's possible that won't match the current branch's remote.

For example, if my current branch's remote is origin, but I have in my config:

[remote "production"]
	url = [email protected]:Fryguy/my_repo.git
	fetch = +refs/heads/*:refs/remotes/production/*
[remote "origin"]
	url = [email protected]:Fryguy/my_repo.git
	fetch = +refs/heads/*:refs/remotes/origin/*

then, what happens is that this code detects the default_host as the gitlab one, but this code will never detect the remote origin + regex + gitlab host because that combination doesn't exist.

I'm not sure how to fix this, as there are multiple paths, and I'm not a python dev, so I'm having trouble contributing. Some choices can be

  • Have multiple default_hosts and try all of them with every remote
  • Instead of straight regexes against the .git/config, parse it such that you get a dictionary of remote name => url. Then, for whatever the current branch's remote is, grab that url and parse the host out of that. At that point I don't think you need the default_host code at all.

Fryguy avatar Mar 26 '18 20:03 Fryguy

Can we use ConfigParser? https://docs.python.org/2/library/configparser.html

Fryguy avatar Mar 26 '18 20:03 Fryguy