aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-05-20 17:16:06 +0100
committerGitHub <noreply@github.com>2020-05-20 19:16:06 +0300
commitc81ab17de93ee14268ad2088d1b63e0162e3dd23 (patch)
tree5c6f9af4f8b9c1e4597807772a6788781dcfc96f /cmd
parent0903b1ac8c7b64bb571d02cdd69fa671cc1c18c1 (diff)
downloadgitea-c81ab17de93ee14268ad2088d1b63e0162e3dd23.tar.gz
gitea-c81ab17de93ee14268ad2088d1b63e0162e3dd23.zip
TrimSpace when reading InternalToken from a file (#11502)
InternalTokens are fixed as alphanum strings therefore TrimSpace from these. Also use isatty to not add a terminal newline when redirecting generate. Fix #11498 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/generate.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/cmd/generate.go b/cmd/generate.go
index 4e91b1d3f0..13a99c94f4 100644
--- a/cmd/generate.go
+++ b/cmd/generate.go
@@ -7,9 +7,11 @@ package cmd
import (
"fmt"
+ "os"
"code.gitea.io/gitea/modules/generate"
+ "github.com/mattn/go-isatty"
"github.com/urfave/cli"
)
@@ -59,7 +61,12 @@ func runGenerateInternalToken(c *cli.Context) error {
return err
}
- fmt.Printf("%s\n", internalToken)
+ fmt.Printf("%s", internalToken)
+
+ if isatty.IsTerminal(os.Stdout.Fd()) {
+ fmt.Printf("\n")
+ }
+
return nil
}
@@ -69,7 +76,12 @@ func runGenerateLfsJwtSecret(c *cli.Context) error {
return err
}
- fmt.Printf("%s\n", JWTSecretBase64)
+ fmt.Printf("%s", JWTSecretBase64)
+
+ if isatty.IsTerminal(os.Stdout.Fd()) {
+ fmt.Printf("\n")
+ }
+
return nil
}
@@ -79,6 +91,11 @@ func runGenerateSecretKey(c *cli.Context) error {
return err
}
- fmt.Printf("%s\n", secretKey)
+ fmt.Printf("%s", secretKey)
+
+ if isatty.IsTerminal(os.Stdout.Fd()) {
+ fmt.Printf("\n")
+ }
+
return nil
}