Repository navigation
Conversation
Returns proxy string from Git config first and environment second.
|
This looks great :) My main question is whether this should prefer the git config or the environment first? I'd lean towards using the git config as a last resort. A couple use cases:
I'd like to see how git handles this. A go test for An integration test would be lovely. It'd require setting up a fake proxy server for testing purposes. I can look into this separately, since it should've existed for the current env proxy support. |
|
+1 to @technoweenie's comments. Environment vars should always override gitconfig settings, it's how you typically change things temporarily rather than persistently. |
Add three go tests and only one works right now
|
@LizzHale and I paired on this again today and we think we've got the logic right but haven't figured out how to correctly test all of them. One of our tests works and two don't, we left them there but commented out with the error. Any *pointers are appreciated 😁 |
|
Hi @jonmagic and @LizzHale! This looks awesome 👍 I definitely agree with @technoweenie and @sinbad's comment about the environment vs. Tests look like they're off to a good start, too. If you post more of the stacktrace, I'd be more than happy to take a look at it with you and try and figure out the cause of the failure 😄 |
| // panic: runtime error: invalid memory address or nil pointer dereference [recovered] | ||
| // panic: runtime error: invalid memory address or nil pointer dereference | ||
| // | ||
| // func TestProxyFromEnv(t *testing.T) { |
There was a problem hiding this comment.
Stacktrace:
warning: current Git remote contains credentials
warning: current Git remote contains credentials
--- FAIL: TestProxyFromEnv (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0xe1a2a]
goroutine 287 [running]:
panic(0x4cef80, 0xc82000a0f0)
/usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6
testing.tRunner.func1(0xc820366000)
/usr/local/Cellar/go/1.6.2/libexec/src/testing/testing.go:467 +0x192
panic(0x4cef80, 0xc82000a0f0)
/usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:443 +0x4e9
github.com/github/git-lfs/lfs.TestProxyFromEnv(0xc820366000)
/Users/jonmagic/gopath/src/github.com/github/git-lfs/lfs/proxy_test.go:29 +0x34a
testing.tRunner(0xc820366000, 0x7d4368)
/usr/local/Cellar/go/1.6.2/libexec/src/testing/testing.go:473 +0x98
created by testing.RunTests
/usr/local/Cellar/go/1.6.2/libexec/src/testing/testing.go:582 +0x892
FAIL github.com/github/git-lfs/lfs 1.285s
ok github.com/github/git-lfs/git 1.636s
There was a problem hiding this comment.
So the relevant bit here is this:
github.com/github/git-lfs/lfs.TestProxyFromEnv(0xc820366000)
/Users/jonmagic/gopath/src/github.com/github/git-lfs/lfs/proxy_test.go:29 +0x34a
This is telling me that the TestProxyFromEnv() function on proxy_test.go:29 is failing due to a nil pointer reference. Going by the commented test line numbers, that's coming from the middle line here, because proxyURL is nil.
proxyURL, err := proxyFromGitConfigOrEnvironment(req)
assert.Equal(t, "proxy-from-env:8080", proxyURL.Host)
assert.Equal(t, nil, err)You should check err before the value to avoid issues like this.
|
Closing in favor of #1358 |
This may be a possible solution to #1125 but we are Go and git-lfs newbs so we could use some guidance.
/cc @LizzHale