MCPcopy
hub / github.com/go-git/go-git / injectGpgSig

Function injectGpgSig

tests/objectverify/main_test.go:354–369  ·  view source on GitHub ↗
(unsigned []byte, sig string)

Source from the content-addressed store, hash-verified

352}
353
354func injectGpgSig(unsigned []byte, sig string) []byte {
355 sep := []byte("\n\n")
356 idx := bytes.Index(unsigned, sep)
357 if idx < 0 {
358 panic("injectGpgSig: no header/body separator")
359 }
360 sig = strings.TrimSuffix(sig, "\n")
361 indented := strings.ReplaceAll(sig, "\n", "\n ")
362 headerLine := "gpgsig " + indented + "\n"
363
364 var buf bytes.Buffer
365 buf.Write(unsigned[:idx+1]) // up to and including the \n that ends the last header
366 buf.WriteString(headerLine) // gpgsig + indented sig + closing \n
367 buf.Write(unsigned[idx+1:]) // empty-line \n + body
368 return buf.Bytes()
369}

Callers 2

Calls 3

IndexMethod · 0.65
WriteMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…