Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple, different, remotes can break detection #62

Open
Fryguy opened this issue Mar 26, 2018 · 1 comment
Open

multiple, different, remotes can break detection #62

Fryguy opened this issue Mar 26, 2018 · 1 comment

Comments

@Fryguy
Copy link

Fryguy commented Mar 26, 2018

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 = git@gitlab.example.com:Fryguy/my_repo.git
	fetch = +refs/heads/*:refs/remotes/production/*
[remote "origin"]
	url = git@github.com: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
Copy link
Author

Fryguy commented Mar 26, 2018

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

Fryguy added a commit to Fryguy/GitHubinator that referenced this issue Mar 27, 2018
This allows for a more accurate parsing of the file since we known the
sections and values within those sections.

Fixes ehamiter#62
Fryguy added a commit to Fryguy/GitHubinator that referenced this issue Mar 27, 2018
This allows for a more accurate parsing of the file since we known the
sections and values within those sections.

Fixes ehamiter#62
Fryguy added a commit to Fryguy/GitHubinator that referenced this issue Mar 27, 2018
This allows for a more accurate parsing of the file since we know the
sections, and values within those sections.

Fixes ehamiter#62
Fryguy added a commit to Fryguy/GitHubinator that referenced this issue Mar 27, 2018
This allows for a more accurate parsing of the file since we know the
sections, and values within those sections.

Fixes ehamiter#62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant