mirror of
https://github.com/golang/go
synced 2024-09-28 23:14:38 -06:00
cmd/go: run the gpg command verbosely in TestScript/version_buildvcs_git_gpg
Also update test helper programs to avoid the deprecated io/ioutil package and fix minor formatting issues. For #49649. Change-Id: Id404acbb2795470420854d682f849d959d2080c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/453775 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
parent
61f5a672ed
commit
bb0d8297d7
@ -11,7 +11,7 @@ mkdir $GNUPGHOME
|
||||
chmod 0700 $GNUPGHOME
|
||||
|
||||
# Create GPG key
|
||||
exec gpg --batch --passphrase '' --quick-generate-key gopher@golang.org
|
||||
exec gpg --batch --passphrase '' --quick-generate-key --verbose gopher@golang.org
|
||||
exec gpg --list-secret-keys --with-colons gopher@golang.org
|
||||
cp stdout keyinfo.txt
|
||||
go run extract_key_id.go keyinfo.txt
|
||||
@ -53,53 +53,55 @@ func main() {}
|
||||
-- extract_key_id.go --
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "io/ioutil"
|
||||
import "os"
|
||||
import "strings"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := run(os.Args[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err := run(os.Args[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(keyInfoFilePath string) error {
|
||||
contents, err := ioutil.ReadFile(keyInfoFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lines := strings.Split(string(contents), "\n")
|
||||
for _, line := range lines {
|
||||
fields := strings.Split(line, ":")
|
||||
if fields[0] == "sec" {
|
||||
fmt.Print(fields[4])
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("key ID not found in: %s", keyInfoFilePath)
|
||||
contents, err := os.ReadFile(keyInfoFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lines := strings.Split(string(contents), "\n")
|
||||
for _, line := range lines {
|
||||
fields := strings.Split(line, ":")
|
||||
if fields[0] == "sec" {
|
||||
fmt.Print(fields[4])
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("key ID not found in: %s", keyInfoFilePath)
|
||||
}
|
||||
|
||||
-- configure_signing_key.go --
|
||||
package main
|
||||
|
||||
import "io/ioutil"
|
||||
import "os"
|
||||
import "os/exec"
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := run(os.Args[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err := run(os.Args[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(keyIdFilePath string) error {
|
||||
keyId, err := ioutil.ReadFile(keyIdFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gitCmd := exec.Command("git", "config", "user.signingKey", string(keyId))
|
||||
return gitCmd.Run()
|
||||
keyId, err := os.ReadFile(keyIdFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gitCmd := exec.Command("git", "config", "user.signingKey", string(keyId))
|
||||
return gitCmd.Run()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user