Use configparser to parse the .git/config #65
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows for a more accurate parsing of the file since we know the
sections, and values within those sections.
Fixes #62
I took a crack at using configparser to parse the .git/config file, but I'm leaving this PR as WIP because it actually blows up on some .git/config files I have where there are duplicate sections with the same name (though the duplicate sections are empty). I'm not sure how to force my .git/config into being like that, so if I figure it out, I'll put it here. If configparser can't be used, it might be better to just build a simple, custom, parser or find a way around how configparser deals with duplicate but empty sections.The two regexes on lines 72 and 86 can probably be smashed together to make the code simpler, but I didn't want to mess with them in this PR, mostly reusing the original ones.
This is my first time writing Python, so if what I've written is not Pythonic, please let me know and I can fix it up. Are there tests I should be writing somewhere? I didn't see any tests, so I wasn't sure.