Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions internal/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"net/http"
"os"
"reflect"
"strings"
"sync"
"time"

"github.com/slackapi/slack-cli/internal/api"
"github.com/slackapi/slack-cli/internal/goutils"
"github.com/slackapi/slack-cli/internal/shared"
"github.com/slackapi/slack-cli/internal/slackerror"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -223,13 +223,17 @@ func (u *UpdateNotification) isCI() bool {

// isIgnoredCommand returns true when the process is in the list of commands.
func (u *UpdateNotification) isIgnoredCommand() bool {
ignoredCommands := []string{"_fingerprint", "api", "version"}
osStr := os.Args[0:]
if len(osStr) < 2 {
ignoredCommands := []string{"_fingerprint", "api", "manifest info", "version"}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ignoredCommands := []string{"_fingerprint", "api", "manifest info", "version"}
ignoredCommands := []string{"_fingerprint", "api", "manifest", "manifest info", "version"}

🪬 question: Is the shortened command automatic? I prefer extended commands often in scripts but am unsure if this should be covered too.

if len(os.Args) < 2 {
return false
}
commandName := osStr[1]
return goutils.Contains(ignoredCommands, commandName, true)
commandStr := strings.Join(os.Args[1:], " ")
for _, ignored := range ignoredCommands {
if commandStr == ignored || strings.HasPrefix(commandStr, ignored+" ") {
return true
}
}
return false
}

// isLastUpdateCheckedAtGreaterThan returns true when the time since the last update check is greater
Expand Down
11 changes: 10 additions & 1 deletion internal/update/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package update
import (
"context"
"os"
"strings"
"testing"

"github.com/slackapi/slack-cli/internal/config"
Expand Down Expand Up @@ -165,14 +166,22 @@ func Test_UpdateNotification_isIgnoredCommand(t *testing.T) {
command: "version",
expected: true,
},
"manifest info command": {
command: "manifest info",
expected: true,
},
"manifest validate command": {
command: "manifest validate",
expected: false,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️‍🗨️ praise: Thanks! This makes me think much about tests as spec more than unit.

},
"auth command": {
command: "auth",
expected: false,
},
} {
t.Run(name, func(t *testing.T) {
if tc.command != "" {
os.Args = []string{"placeholder", tc.command}
os.Args = append([]string{"placeholder"}, strings.Split(tc.command, " ")...)
} else {
os.Args = []string{"placeholder"}
}
Expand Down
Loading