remote signing help
This commit is contained in:
+3
-1
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
Reference in New Issue
Block a user