]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: run the gpg command verbosely in TestScript/version_buildvcs_git_gpg
authorBryan C. Mills <bcmills@google.com>
Mon, 28 Nov 2022 19:08:12 +0000 (14:08 -0500)
committerGopher Robot <gobot@golang.org>
Mon, 28 Nov 2022 19:38:37 +0000 (19:38 +0000)
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>
src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt

index c88075c5bc7de0d5698d941f6d6ff1aa6f7728e0..077d193f62d626e66615d66d1c1220eed2ccf0ad 100644 (file)
@@ -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()
 }