aboutsummaryrefslogtreecommitdiff
path: root/internal/cmd
diff options
context:
space:
mode:
authordeepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>2022-03-06 16:33:45 +0800
committerGitHub <noreply@github.com>2022-03-06 16:33:45 +0800
commitdeec3516d53e9a9679128ade0556ccc818a67be1 (patch)
treeb5c1c5d55be05a244180ece0b822e7e35dc68f42 /internal/cmd
parent65526f84e1d382ac01b7379f40fc56b2660d1074 (diff)
autofix: fix check for empty string (#6804)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Diffstat (limited to 'internal/cmd')
-rw-r--r--internal/cmd/hook.go8
-rw-r--r--internal/cmd/serv.go14
2 files changed, 10 insertions, 12 deletions
diff --git a/internal/cmd/hook.go b/internal/cmd/hook.go
index 99a5e15b..b58db829 100644
--- a/internal/cmd/hook.go
+++ b/internal/cmd/hook.go
@@ -63,7 +63,7 @@ var (
)
func runHookPreReceive(c *cli.Context) error {
- if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
+ if os.Getenv("SSH_ORIGINAL_COMMAND") == "" {
return nil
}
setup(c, "pre-receive.log", true)
@@ -156,7 +156,7 @@ func runHookPreReceive(c *cli.Context) error {
}
func runHookUpdate(c *cli.Context) error {
- if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
+ if os.Getenv("SSH_ORIGINAL_COMMAND") == "" {
return nil
}
setup(c, "update.log", false)
@@ -164,7 +164,7 @@ func runHookUpdate(c *cli.Context) error {
args := c.Args()
if len(args) != 3 {
fail("Arguments received are not equal to three", "Arguments received are not equal to three")
- } else if len(args[0]) == 0 {
+ } else if args[0] == "" {
fail("First argument 'refName' is empty", "First argument 'refName' is empty")
}
@@ -190,7 +190,7 @@ func runHookUpdate(c *cli.Context) error {
}
func runHookPostReceive(c *cli.Context) error {
- if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
+ if os.Getenv("SSH_ORIGINAL_COMMAND") == "" {
return nil
}
setup(c, "post-receive.log", true)
diff --git a/internal/cmd/serv.go b/internal/cmd/serv.go
index 1f9ef044..8f54be82 100644
--- a/internal/cmd/serv.go
+++ b/internal/cmd/serv.go
@@ -125,13 +125,11 @@ func checkDeployKey(key *db.PublicKey, repo *db.Repository) {
}
}
-var (
- allowedCommands = map[string]db.AccessMode{
- "git-upload-pack": db.AccessModeRead,
- "git-upload-archive": db.AccessModeRead,
- "git-receive-pack": db.AccessModeWrite,
- }
-)
+var allowedCommands = map[string]db.AccessMode{
+ "git-upload-pack": db.AccessModeRead,
+ "git-upload-archive": db.AccessModeRead,
+ "git-receive-pack": db.AccessModeWrite,
+}
func runServ(c *cli.Context) error {
setup(c, "serv.log", true)
@@ -146,7 +144,7 @@ func runServ(c *cli.Context) error {
}
sshCmd := os.Getenv("SSH_ORIGINAL_COMMAND")
- if len(sshCmd) == 0 {
+ if sshCmd == "" {
println("Hi there, You've successfully authenticated, but Gogs does not provide shell access.")
println("If this is unexpected, please log in with password and setup Gogs under another user.")
return nil