Skip to content

Instantly share code, notes, and snippets.

@minux
Created January 15, 2015 09:21
Show Gist options
  • Save minux/ff797f8d80256cb30426 to your computer and use it in GitHub Desktop.
Save minux/ff797f8d80256cb30426 to your computer and use it in GitHub Desktop.
git-codereview patch for go-zh Gerrit instance
diff --git a/git-codereview/api.go b/git-codereview/api.go
index ac61cba..4a67f33 100644
--- a/git-codereview/api.go
+++ b/git-codereview/api.go
@@ -41,15 +41,20 @@ func loadGerritOrigin() {
}
// Gerrit must be set as Git's origin remote.
- origin := getOutput("git", "config", "remote.origin.url")
+ origin := getOutput("git", "config", "remote.origin.pushurl")
+ if origin == "" {
+ origin = getOutput("git", "config", "remote.origin.url")
+ }
if strings.Contains(origin, "//github.com/") {
dief("git origin must be a Gerrit host, not GitHub: %s", origin)
}
if !strings.HasPrefix(origin, "https://") {
- dief("git origin must be an https:// URL: %s", origin)
+ printf("git origin not https, some features will be unavailable")
+ return
}
+
// https:// prefix and then one slash between host and top-level name
if strings.Count(origin, "/") != 3 {
dief("git origin is malformed: %s", origin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment