aboutsummaryrefslogtreecommitdiff
path: root/git_hooks_handle_linux.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 20:21:32 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 20:21:32 +0800
commit71ab9b7f14118f02dd18cd733bd4e0ad19ece590 (patch)
tree0303cbee651a4e1cee62a348d25066b9543f4425 /git_hooks_handle_linux.go
parentgit2d: Remove UTF-8 checks (diff)
downloadforge-71ab9b7f14118f02dd18cd733bd4e0ad19ece590.tar.gz
forge-71ab9b7f14118f02dd18cd733bd4e0ad19ece590.tar.zst
forge-71ab9b7f14118f02dd18cd733bd4e0ad19ece590.zip
config shall no longer be a global variable
Diffstat (limited to 'git_hooks_handle_linux.go')
-rw-r--r--git_hooks_handle_linux.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/git_hooks_handle_linux.go b/git_hooks_handle_linux.go
index 8c8d34b..37afba1 100644
--- a/git_hooks_handle_linux.go
+++ b/git_hooks_handle_linux.go
@@ -34,7 +34,7 @@ var (
// hooksHandler handles a connection from hookc via the
// unix socket.
-func hooksHandler(conn net.Conn) {
+func (s *server) hooksHandler(conn net.Conn) {
var ctx context.Context
var cancel context.CancelFunc
var ucred *syscall.Ucred
@@ -187,7 +187,7 @@ func hooksHandler(conn net.Conn) {
return 1
}
- ok, err := fedauth(ctx, packPass.userID, service, username, packPass.pubkey)
+ ok, err := s.fedauth(ctx, packPass.userID, service, username, packPass.pubkey)
if err != nil {
writeRedError(sshStderr, "Failed to verify federated user identifier %#v: %v", fedUserID, err)
return 1
@@ -247,7 +247,7 @@ func hooksHandler(conn net.Conn) {
writeRedError(sshStderr, "Error creating merge request: %v", err)
return 1
}
- mergeRequestWebURL := fmt.Sprintf("%s/contrib/%d/", genHTTPRemoteURL(packPass.groupPath, packPass.repoName), newMRLocalID)
+ mergeRequestWebURL := fmt.Sprintf("%s/contrib/%d/", s.genHTTPRemoteURL(packPass.groupPath, packPass.repoName), newMRLocalID)
fmt.Fprintln(sshStderr, ansiec.Blue+"Created merge request at", mergeRequestWebURL+ansiec.Reset)
select {
@@ -342,13 +342,13 @@ func hooksHandler(conn net.Conn) {
// treats incoming connections as those from git hook handlers by spawning
// sessions. The listener must be a SOCK_STREAM UNIX domain socket. The
// function itself blocks.
-func serveGitHooks(listener net.Listener) error {
+func (s *server) serveGitHooks(listener net.Listener) error {
for {
conn, err := listener.Accept()
if err != nil {
return err
}
- go hooksHandler(conn)
+ go s.hooksHandler(conn)
}
}