From 3c1a19d31cb8afb235f7ddfbadadf373722a266c Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Mon, 22 Feb 2021 04:22:34 +0800 Subject: [PATCH] Update query parameter and make HTTPS by default (#4) Resolves #2 Resolves #3 Co-authored-by: jolheiser Reviewed-on: https://gitea.com/jolheiser/git-import/pulls/4 Co-authored-by: John Olheiser Co-committed-by: John Olheiser --- main.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index bbfc8db..f953d9a 100644 --- a/main.go +++ b/main.go @@ -15,13 +15,14 @@ import ( var ( Version = "develop" - output string - author string - email string - gpg string - display bool - ssh bool - debug bool + output string + author string + email string + gpg string + display bool + ssh bool + insecure bool + debug bool ) func main() { @@ -66,13 +67,17 @@ func main() { Usage: "GPG key to sign with", Destination: &gpg, }, + &cli.BoolFlag{ + Name: "insecure", + Usage: "Use HTTP instead of HTTPS by default", + Destination: &insecure, + }, &cli.BoolFlag{ Name: "debug", Usage: "Enable debug logging", Destination: &debug, }, } - app.UseShortOptionHandling = true app.Action = doImport if err := app.Run(os.Args); err != nil { @@ -95,8 +100,12 @@ func doImport(ctx *cli.Context) error { return err } if u.Scheme == "" { - u.Scheme = "http" + u.Scheme = "https" + if insecure { + u.Scheme = "http" + } } + u.RawQuery = "git-import=1" beaver.Debugf("Getting git-import from %s", u.String()) res, err := http.Get(u.String())