summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2021-04-29 19:38:57 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2021-05-01 02:34:52 -0600
commit5f64323918520e048cc02eb522aeaf7f814d611b (patch)
tree695f7dd11be1331e4bb701e1442508a8f53b0071
parent5e4f84f2ff741d545c489f730848b498c87f18f1 (diff)
gpgsig v2
-rw-r--r--cmd_command.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/cmd_command.go b/cmd_command.go
index 14fd2e9..d66c9ce 100644
--- a/cmd_command.go
+++ b/cmd_command.go
@@ -38,11 +38,14 @@ type CmdCommit struct {
OriginalOID string // optional
Author *Ident
Committer Ident
- GPGSig string // optional
- Encoding string // optional
- Msg string
- From string
- Merge []string
+ GPGSig struct { // optional
+ Alg string
+ Sig string
+ }
+ Encoding string // optional
+ Msg string
+ From string
+ Merge []string
}
func (c CmdCommit) fiCmdClass() cmdClass { return cmdClassCommand }
@@ -60,9 +63,9 @@ func (c CmdCommit) fiCmdWrite(fiw fiWriter) error {
ez.WriteLine("author", *c.Author)
}
ez.WriteLine("committer", c.Committer)
- if c.GPGSig != "" {
- ez.WriteLine("gpgsig")
- ez.WriteData(c.GPGSig)
+ if c.GPGSig.Alg != "" {
+ ez.WriteLine("gpgsig", c.GPGSig.Alg)
+ ez.WriteData(c.GPGSig.Sig)
}
if c.Encoding != "" {
ez.WriteLine("encoding", c.Encoding)
@@ -110,10 +113,10 @@ func (CmdCommit) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
c.Committer, err = ParseIdent(trimLinePrefix(ez.ReadLine(), "committer "))
ez.Errcheck(err)
- // ('gpgsig' LF data)?
- if ez.PeekLine() == "gpgsig\n" {
- ez.ReadLine()
- c.GPGSig, err = parse_data(ez.ReadLine())
+ // ('gpgsig' SP <alg> LF data)?
+ if strings.HasPrefix(ez.PeekLine(), "gpgsig ") {
+ c.GPGSig.Alg = trimLinePrefix(ez.ReadLine(), "gpgsig ")
+ c.GPGSig.Sig, err = parse_data(ez.ReadLine())
ez.Errcheck(err)
}