+5
-5
cmd/ugitd/main.go
+5
-5
cmd/ugitd/main.go
···
143
143
if err != nil {
144
144
return err
145
145
}
146
-
fi.WriteString("#!/usr/bin/env bash\n")
147
-
fi.WriteString(fmt.Sprintf("%s pre-receive-hook\n", bin))
148
-
fi.WriteString(fmt.Sprintf(`for hook in %s.d/*; do
146
+
fmt.Fprintln(fi, "#!/usr/bin/env bash")
147
+
fmt.Fprintf(fi, "%s pre-receive-hook\n", bin)
148
+
fmt.Fprintf(fi, `for hook in %s.d/*; do
149
149
test -x "${hook}" && test -f "${hook}" || continue
150
150
"${hook}"
151
-
done`, fp))
151
+
done`, fp)
152
152
fi.Close()
153
153
154
154
return os.Chmod(fp, 0o755)
···
162
162
163
163
opts := make([]*packp.Option, 0)
164
164
if pushCount, err := strconv.Atoi(os.Getenv("GIT_PUSH_OPTION_COUNT")); err == nil {
165
-
for idx := 0; idx < pushCount; idx++ {
165
+
for idx := range pushCount {
166
166
opt := os.Getenv(fmt.Sprintf("GIT_PUSH_OPTION_%d", idx))
167
167
kv := strings.SplitN(opt, "=", 2)
168
168
if len(kv) == 2 {
+2
-2
internal/git/grep.go
+2
-2
internal/git/grep.go
···
18
18
19
19
// Grep performs a naive "code search" via git grep
20
20
func (r Repo) Grep(search string) ([]GrepResult, error) {
21
-
if strings.HasPrefix(search, "=") {
22
-
search = regexp.QuoteMeta(strings.TrimPrefix(search, "="))
21
+
if after, ok := strings.CutPrefix(search, "="); ok {
22
+
search = regexp.QuoteMeta(after)
23
23
}
24
24
re, err := regexp.Compile(search)
25
25
if err != nil {
+1
-1
internal/ssh/ssh.go
+1
-1
internal/ssh/ssh.go
+1
-1
internal/ssh/wish.go
+1
-1
internal/ssh/wish.go
···
168
168
}
169
169
170
170
// Fatal prints to the session's STDOUT as a git response and exit 1.
171
-
func Fatal(s ssh.Session, v ...interface{}) {
171
+
func Fatal(s ssh.Session, v ...any) {
172
172
msg := fmt.Sprint(v...)
173
173
// hex length includes 4 byte length prefix and ending newline
174
174
pktLine := fmt.Sprintf("%04x%s\n", len(msg)+5, msg)