aboutsummaryrefslogtreecommitdiff
path: root/forged/internal/ipc/git2c/cmd_init_repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'forged/internal/ipc/git2c/cmd_init_repo.go')
-rw-r--r--forged/internal/ipc/git2c/cmd_init_repo.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/forged/internal/ipc/git2c/cmd_init_repo.go b/forged/internal/ipc/git2c/cmd_init_repo.go
new file mode 100644
index 0000000..ae1e92a
--- /dev/null
+++ b/forged/internal/ipc/git2c/cmd_init_repo.go
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
+
+package git2c
+
+import "fmt"
+
+func (c *Client) InitRepo(repoPath, hooksPath string) error {
+ if err := c.writer.WriteData([]byte(repoPath)); err != nil {
+ return fmt.Errorf("sending repo path failed: %w", err)
+ }
+ if err := c.writer.WriteUint(15); err != nil {
+ return fmt.Errorf("sending command failed: %w", err)
+ }
+ if err := c.writer.WriteData([]byte(hooksPath)); err != nil {
+ return fmt.Errorf("sending hooks path failed: %w", err)
+ }
+ status, err := c.reader.ReadUint()
+ if err != nil {
+ return fmt.Errorf("reading status failed: %w", err)
+ }
+ if status != 0 {
+ return Perror(status)
+ }
+ return nil
+}