aboutsummaryrefslogtreecommitdiff
path: root/git_hooks_handle.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-17 13:00:56 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-17 13:02:06 +0800
commit0a91277e257752e6414d4f514f970e43242bd533 (patch)
treec07b76fe801fcba69e349b8563f1815bf59e134e /git_hooks_handle.go
parentgit_hooks_client.c: Splice socket to stderr (diff)
downloadforge-0a91277e257752e6414d4f514f970e43242bd533.tar.gz
forge-0a91277e257752e6414d4f514f970e43242bd533.tar.zst
forge-0a91277e257752e6414d4f514f970e43242bd533.zip
git_hooks_handle.go, etc.: Listen for connections from hooks
Diffstat (limited to 'git_hooks_handle.go')
-rw-r--r--git_hooks_handle.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/git_hooks_handle.go b/git_hooks_handle.go
index 86300cb..f650436 100644
--- a/git_hooks_handle.go
+++ b/git_hooks_handle.go
@@ -31,11 +31,21 @@ func hooks_handle_connection(conn net.Conn) (err error) {
pid := ucred.Pid
- _ = pid
+ conn.Write([]byte{0})
+ fmt.Fprintf(conn, "your PID is %d\n", pid)
return nil
}
+func serve_git_hooks(listener net.Listener) error {
+ conn, err := listener.Accept()
+ if err != nil {
+ return err
+ }
+
+ return hooks_handle_connection(conn)
+}
+
func get_ucred(fd *os.File) (*syscall.Ucred, error) {
ucred, err := syscall.GetsockoptUcred(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_PEERCRED)
if err != nil {