Skip to content

Commit 94f15e4

Browse files
fentasclaude
andcommitted
fix(preset): ssh-to-age now uses -version flag instead of SHA hash workaround
ssh-to-age gained a -version flag (prints bare version like "1.2.0"). Replace the old SHA256-hash-of-help-output workaround with a direct '-version' call. Prepend 'v' prefix so it matches GithubLatest's "v1.3.0" format for the skip comparison. Removes the hardcoded versions map and the crypto/sha256 import. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4ef01e8 commit 94f15e4

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

pkg/binaries/ssh-to-age/ssh-to-age.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,14 @@ package sshtoage
33

44
import (
55
"context"
6-
"crypto/sha256"
76
"fmt"
87
"runtime"
8+
"strings"
99

1010
"github.com/fentas/b/pkg/binaries"
1111
"github.com/fentas/b/pkg/binary"
1212
)
1313

14-
// workaround for version lookup
15-
// wait for fix https://github.com/Mic92/ssh-to-age/issues/180
16-
// or get binary sha https://github.com/fentas/b/issues/76
17-
var versions = map[string]string{
18-
"73513156cc8821915ff96b83a9a5780a2993199497c2a3106795de1c54429578": "1.2.0",
19-
}
20-
2114
func Binary(options *binaries.BinaryOptions) *binary.Binary {
2215
if options == nil {
2316
options = &binaries.BinaryOptions{
@@ -35,20 +28,17 @@ func Binary(options *binaries.BinaryOptions) *binary.Binary {
3528
VersionF: binary.GithubLatest,
3629
IsTarGz: false,
3730
VersionLocalF: func(b *binary.Binary) (string, error) {
38-
s, err := b.Exec("-h")
31+
// ssh-to-age -version prints a bare version like "1.2.0".
32+
// GithubLatest returns "v1.2.0", so prepend "v" for comparison.
33+
s, err := b.Exec("-version")
3934
if err != nil {
4035
return "", err
4136
}
42-
// create hash from output
43-
hash := sha256.New()
44-
if _, err := hash.Write([]byte(s)); err != nil {
45-
return "", err
46-
}
47-
v := fmt.Sprintf("%x", hash.Sum(nil))
48-
if _, ok := versions[v]; !ok {
49-
return v, nil
37+
v := strings.TrimSpace(s)
38+
if v != "" && !strings.HasPrefix(v, "v") {
39+
v = "v" + v
5040
}
51-
return versions[v], nil
41+
return v, nil
5242
},
5343
}
5444
}

0 commit comments

Comments
 (0)