diff --git a/cmd/ugitd/main.go b/cmd/ugitd/main.go index 6dfa3d9dfefc302d856bf424042d2e9d6444b1e5..afb48cd348805b04c0f4ae04c0d510903740e3d9 100644 --- a/cmd/ugitd/main.go +++ b/cmd/ugitd/main.go @@ -143,12 +143,12 @@ fi, err := os.Create(fp) if err != nil { return err } - fmt.Fprintln(fi, "#!/usr/bin/env bash") - fmt.Fprintf(fi, "%s pre-receive-hook\n", bin) - fmt.Fprintf(fi, `for hook in %s.d/*; do + fi.WriteString("#!/usr/bin/env bash\n") + fi.WriteString(fmt.Sprintf("%s pre-receive-hook\n", bin)) + fi.WriteString(fmt.Sprintf(`for hook in %s.d/*; do test -x "${hook}" && test -f "${hook}" || continue "${hook}" -done`, fp) +done`, fp)) fi.Close() return os.Chmod(fp, 0o755) @@ -162,7 +162,7 @@ } opts := make([]*packp.Option, 0) if pushCount, err := strconv.Atoi(os.Getenv("GIT_PUSH_OPTION_COUNT")); err == nil { - for idx := range pushCount { + for idx := 0; idx < pushCount; idx++ { opt := os.Getenv(fmt.Sprintf("GIT_PUSH_OPTION_%d", idx)) kv := strings.SplitN(opt, "=", 2) if len(kv) == 2 { diff --git a/internal/git/grep.go b/internal/git/grep.go index f92567d4773ac253a73afbb95efe1b53d0cdde06..d10c933d7ff46488ec10e45f75660a84df577b8f 100644 --- a/internal/git/grep.go +++ b/internal/git/grep.go @@ -18,8 +18,8 @@ } // Grep performs a naive "code search" via git grep func (r Repo) Grep(search string) ([]GrepResult, error) { - if after, ok := strings.CutPrefix(search, "="); ok { - search = regexp.QuoteMeta(after) + if strings.HasPrefix(search, "=") { + search = regexp.QuoteMeta(strings.TrimPrefix(search, "=")) } re, err := regexp.Compile(search) if err != nil { diff --git a/internal/ssh/ssh.go b/internal/ssh/ssh.go index e094092d5ee3f6c8cf5225af8e9c71f87dba72f2..a6dec7bb45c58d5296809093af2ade15913736d9 100644 --- a/internal/ssh/ssh.go +++ b/internal/ssh/ssh.go @@ -48,4 +48,4 @@ ) type noopLogger struct{} -func (n noopLogger) Printf(format string, v ...any) {} +func (n noopLogger) Printf(format string, v ...interface{}) {} diff --git a/internal/ssh/wish.go b/internal/ssh/wish.go index 6bdb16748ec5499af03d1f4683800da71eb612ab..bdf504b0e0a2f14a4d7105dd1e9353f57b8fe807 100644 --- a/internal/ssh/wish.go +++ b/internal/ssh/wish.go @@ -168,7 +168,7 @@ } } // Fatal prints to the session's STDOUT as a git response and exit 1. -func Fatal(s ssh.Session, v ...any) { +func Fatal(s ssh.Session, v ...interface{}) { msg := fmt.Sprint(v...) // hex length includes 4 byte length prefix and ending newline pktLine := fmt.Sprintf("%04x%s\n", len(msg)+5, msg)