remote signing help

This commit is contained in:
Ian Gulliver
2026-10-19 11:38:19 -07:00
parent fad610d5e7
commit 7965e9025a
4 changed files with 49 additions and 1 deletions
+3 -1
View File
@@ -20,13 +20,15 @@ func main() {
checkCmd()
case "run":
runCmd(os.Args[2:])
case "signing":
signingCmd(os.Args[2:])
default:
usage()
}
}
func usage() {
fmt.Fprintln(os.Stderr, "usage: byre serve | byre install | byre check | byre run [--resume ID]")
fmt.Fprintln(os.Stderr, "usage: byre serve | byre install | byre check | byre run [--resume ID] | byre signing CHECKOUT")
os.Exit(2)
}
+41
View File
@@ -0,0 +1,41 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
func signingCmd(args []string) {
if len(args) != 1 {
usage()
}
checkout := args[0]
common := gitOut(checkout, "rev-parse", "--path-format=absolute", "--git-common-dir")
if gitOut(checkout, "rev-parse", "--path-format=absolute", "--git-dir") != common {
fatal("checkout is a linked worktree; run byre signing on its main checkout", "checkout", checkout)
}
unsigned := filepath.Join(common, "unsigned.gitconfig")
gitOut(checkout, "config", "commit.gpgsign", "true")
gitOut(checkout, "config", "--file", unsigned, "commit.gpgsign", "false")
gitOut(checkout, "config", "includeIf.gitdir:"+filepath.Join(common, "worktrees")+"/**.path", "unsigned.gitconfig")
signing := gitOut(checkout, "config", "--type=bool", "--get", "commit.gpgsign")
if signing != "true" {
fatal("checkout's commit.gpgsign is not true after setting it", "checkout", checkout, "value", signing)
}
fmt.Printf("%s: commit.gpgsign %s\n", checkout, signing)
fmt.Printf("%s/worktrees/*: commit.gpgsign %s\n", common, gitOut(checkout, "config", "--file", unsigned, "--type=bool", "--get", "commit.gpgsign"))
}
func gitOut(dir string, args ...string) string {
cmd := exec.Command("git", args...)
cmd.Dir = dir
cmd.Stderr = os.Stderr
out, err := cmd.Output()
if err != nil {
fatal("git failed", "args", strings.Join(args, " "), "err", err)
}
return strings.TrimSpace(string(out))
}