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

x/review: pickup URL specific http.cookieFile from the git config #35496

Closed
quite opened this issue Nov 11, 2019 · 4 comments

Comments

@quite
Copy link

@quite quite commented Nov 11, 2019

git-codereview does not pick up an URL-specific cookieFile, like: http.{URL}.cookieFile. Looks like this in the config file:

[http "https://go.googlesource.com"]
        cookiefile = ~/.gitcookies-googlesource

git config does have a way to do that matching (--get-urlmatch which is nothing new), which also falls back to any non-URL-specific http.cookieFile.

The following works, but it is clearly not covered by the tests (but they do pass).

diff --git a/git-codereview/api.go b/git-codereview/api.go
index 8440cb5..a3375ea 100644
--- a/git-codereview/api.go
+++ b/git-codereview/api.go
@@ -145,7 +145,7 @@ func loadAuth() {
 
 	// First look in Git's http.cookiefile, which is where Gerrit
 	// now tells users to store this information.
-	if cookieFile, _ := trimErr(cmdOutputErr("git", "config", "--path", "http.cookiefile")); cookieFile != "" {
+	if cookieFile, _ := trimErr(cmdOutputErr("git", "config", "--path", "--get-urlmatch", "http.cookiefile", auth.url)); cookieFile != "" {
 		data, _ := ioutil.ReadFile(cookieFile)
 		maxMatch := -1
 		for _, line := range lines(string(data)) {
@gopherbot gopherbot added this to the Unreleased milestone Nov 11, 2019
@andybons

This comment has been minimized.

Copy link
Member

@andybons andybons commented Nov 11, 2019

@josharian

This comment has been minimized.

Copy link
Contributor

@josharian josharian commented Nov 11, 2019

Thanks. Want to send a fix?

@quite

This comment has been minimized.

Copy link
Author

@quite quite commented Nov 12, 2019

I can submit the above patch on gerrit but i don't really have time now to rewrite/add tests to accomodate for it..

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 12, 2019

Change https://golang.org/cl/206697 mentions this issue: git-codereview: pick up URL-specific cookieFile config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.