Update query parameter and make HTTPS by default

Signed-off-by: jolheiser <john.olheiser@gmail.com>
pull/4/head
jolheiser 2021-02-21 14:20:28 -06:00
parent 9222b99fd1
commit da9af5a9b2
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 18 additions and 9 deletions

27
main.go
View File

@ -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())