Repository navigation
use proxy from git config - #1358
Conversation
Returns proxy string from Git config first and environment second.
Add three go tests and only one works right now
|
@technoweenie awesome! Just getting back from vacation, anything I can do to help on this? |
|
👍 |
|
|
||
| assert.Nil(t, proxyURL) | ||
| assert.Nil(t, err) | ||
| } |
There was a problem hiding this comment.
I think there should be some tests with NO_PROXY for completeness.
|
👍 looks good |
|
Hey, funny story time. @ttaylorr asked me why the function is named
I never looked into it until just now though, while looking for any other proxy related git config values. The docs say:
Looks like @jonmagic and @LizzHale are right :) I wonder if a git |
|
This is a great point - I even checked the precedence and agreed with it, but now you raise it again I think this does need to be the other way around in this case. Usually environment variables should override gitconfig, but in this case the environment variables are general ones, not git specific ones. Thinking about it, it makes sense that the overall order of precedence should be:
.. because otherwise you have no way of persistently overriding generic environment settings specifically for git. The confusion I've had is that we've only really had 1 & 2 most of the time. |
|
I updated the code to check the git config first 👍 |
|
Looks good! ✨ |
|
✨ |
This updates #1173 with the latest master. Since that PR, a lot of subpackages have been split out, and we've switched assertion libraries.
@jonmagic @LizzHale: I also changed the main
ProxyFromGitConfigOrEnvironment()function from #1173 for these reasons:proxyFromGitConfigOrEnvironment()is coupled to the globalConfigvalue. I updated the function to accept only a*config.Configurationargument, and return afunc(*http.Request) (*url.URL, error). That cleaned up the test setup forTestProxyFromGitConfiga bit.http.ProxyFromEnvironmentnow. I didn't want to drop a potential error if users have a bad HTTPS_PROXY value, but a good githttp.proxyvalue.nilnow, explicitly.Unfortunately, I couldn't test the environment, because of how
http.ProxyFromEnvironmentis implemented. It reads from the env the first time that function is called. Callingos.Setenvdoesn't affect it.However, I'm thinking about pulling all that code into Git LFS. There are a few internal functions that would be useful for proxy values specified in the git config, such as
NO_PROXYhandling.