Home

ugit @main - refs - log -
-
https://git.jolheiser.com/ugit.git
The code powering this h*ckin' site
tree log patch
modernize Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQPx39D6IFXqre5y9QM430CIoG9SEm7JlPpIkcHQUU3fTe7iJGlDEgNxMUGKy6cBQxl EzMsjXnFHEdzOIDvhKlwc= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
4 days ago
4 changed files, 9 additions(+), 9 deletions(-)
cmd/ugitd/main.gointernal/git/grep.gointernal/ssh/ssh.gointernal/ssh/wish.go
M cmd/ugitd/main.go -> cmd/ugitd/main.go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
diff --git a/cmd/ugitd/main.go b/cmd/ugitd/main.go
index afb48cd348805b04c0f4ae04c0d510903740e3d9..6dfa3d9dfefc302d856bf424042d2e9d6444b1e5 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
 	}
-	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
+	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
 	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 := 0; idx < pushCount; idx++ {
+		for idx := range pushCount {
 			opt := os.Getenv(fmt.Sprintf("GIT_PUSH_OPTION_%d", idx))
 			kv := strings.SplitN(opt, "=", 2)
 			if len(kv) == 2 {
M internal/git/grep.go -> internal/git/grep.go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
diff --git a/internal/git/grep.go b/internal/git/grep.go
index d10c933d7ff46488ec10e45f75660a84df577b8f..f92567d4773ac253a73afbb95efe1b53d0cdde06 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 strings.HasPrefix(search, "=") {
-		search = regexp.QuoteMeta(strings.TrimPrefix(search, "="))
+	if after, ok := strings.CutPrefix(search, "="); ok {
+		search = regexp.QuoteMeta(after)
 	}
 	re, err := regexp.Compile(search)
 	if err != nil {
M internal/ssh/ssh.go -> internal/ssh/ssh.go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
diff --git a/internal/ssh/ssh.go b/internal/ssh/ssh.go
index a6dec7bb45c58d5296809093af2ade15913736d9..e094092d5ee3f6c8cf5225af8e9c71f87dba72f2 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 ...interface{}) {}
+func (n noopLogger) Printf(format string, v ...any) {}
M internal/ssh/wish.go -> internal/ssh/wish.go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
diff --git a/internal/ssh/wish.go b/internal/ssh/wish.go
index bdf504b0e0a2f14a4d7105dd1e9353f57b8fe807..6bdb16748ec5499af03d1f4683800da71eb612ab 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 ...interface{}) {
+func Fatal(s ssh.Session, v ...any) {
 	msg := fmt.Sprint(v...)
 	// hex length includes 4 byte length prefix and ending newline
 	pktLine := fmt.Sprintf("%04x%s\n", len(msg)+5, msg)