X Tutup
Skip to content

Commit 6f66a1d

Browse files
authored
Add version to extension list command (cli#5219)
* Add version to extension list command * Trim sha only when displaying
1 parent cd8d653 commit 6f66a1d

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

pkg/cmd/extension/command.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ func NewCmdExtension(f *cmdutil.Factory) *cobra.Command {
6161

6262
t.AddField(fmt.Sprintf("gh %s", c.Name()), nil, nil)
6363
t.AddField(repo, nil, nil)
64+
version := c.CurrentVersion()
65+
if !c.IsBinary() && len(version) > 8 {
66+
version = version[:8]
67+
}
68+
t.AddField(version, nil, nil)
6469
var updateAvailable string
6570
if c.UpdateAvailable() {
6671
updateAvailable = "Upgrade available"

pkg/cmd/extension/command_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func TestNewCmdExtension(t *testing.T) {
299299
assert.Equal(t, 1, len(em.ListCalls()))
300300
}
301301
},
302-
wantStdout: "gh test\tcli/gh-test\t\ngh test2\tcli/gh-test2\tUpgrade available\n",
302+
wantStdout: "gh test\tcli/gh-test\t1\t\ngh test2\tcli/gh-test2\t1\tUpgrade available\n",
303303
},
304304
{
305305
name: "create extension interactive",

pkg/cmd/extension/extension.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func (e *Extension) IsLocal() bool {
3939
return e.isLocal
4040
}
4141

42+
func (e *Extension) CurrentVersion() string {
43+
return e.currentVersion
44+
}
45+
4246
func (e *Extension) UpdateAvailable() bool {
4347
if e.isLocal ||
4448
e.currentVersion == "" ||

pkg/extensions/extension.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Extension interface {
2020
Path() string // Path to executable
2121
URL() string
2222
IsLocal() bool
23+
CurrentVersion() string
2324
UpdateAvailable() bool
2425
IsBinary() bool
2526
}

pkg/extensions/extension_mock.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
X Tutup