aboutsummaryrefslogtreecommitdiff
path: root/git_hooks_handle.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-22 11:14:34 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-22 11:14:34 +0800
commit509164574a1ed644655155be5dd087c1192de1f9 (patch)
tree7690fb67f2bdbfa8d1a3ab468b54b62999f7c384 /git_hooks_handle.go
parentLog incoming and outgoing messages (diff)
downloadforge-509164574a1ed644655155be5dd087c1192de1f9.tar.gz
forge-509164574a1ed644655155be5dd087c1192de1f9.tar.zst
forge-509164574a1ed644655155be5dd087c1192de1f9.zip
Allow anonymous MRs...?
Diffstat (limited to 'git_hooks_handle.go')
-rw-r--r--git_hooks_handle.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/git_hooks_handle.go b/git_hooks_handle.go
index 11a117a..6a44784 100644
--- a/git_hooks_handle.go
+++ b/git_hooks_handle.go
@@ -226,10 +226,17 @@ func hooksHandler(conn net.Conn) {
fmt.Fprintln(sshStderr, ansiec.Blue+"POK"+ansiec.Reset, refName)
var newMRID int
- err = database.QueryRow(ctx,
- "INSERT INTO merge_requests (repo_id, creator, source_ref, status) VALUES ($1, $2, $3, 'open') RETURNING id",
- packPass.repoID, packPass.userID, strings.TrimPrefix(refName, "refs/heads/"),
- ).Scan(&newMRID)
+ if packPass.userID != 0 {
+ err = database.QueryRow(ctx,
+ "INSERT INTO merge_requests (repo_id, creator, source_ref, status) VALUES ($1, $2, $3, 'open') RETURNING id",
+ packPass.repoID, packPass.userID, strings.TrimPrefix(refName, "refs/heads/"),
+ ).Scan(&newMRID)
+ } else {
+ err = database.QueryRow(ctx,
+ "INSERT INTO merge_requests (repo_id, source_ref, status) VALUES ($1, $2, 'open') RETURNING id",
+ packPass.repoID, strings.TrimPrefix(refName, "refs/heads/"),
+ ).Scan(&newMRID)
+ }
if err != nil {
writeRedError(sshStderr, "Error creating merge request: %v", err)
return 1