From: Bryan C. Mills Date: Mon, 28 Nov 2022 19:08:12 +0000 (-0500) Subject: cmd/go: run the gpg command verbosely in TestScript/version_buildvcs_git_gpg X-Git-Tag: go1.20rc1~75 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bb0d8297d76cb578baad8fa1485565d9acf44cc5;p=gostls13.git 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 Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Carlos Amedee --- diff --git a/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt b/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt index c88075c5bc..077d193f62 100644 --- a/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt +++ b/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt @@ -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() }