Skip to content

Commit e9ace37

Browse files
authored
fix: skip automatic update check for api command with arguments (#568)
1 parent dc30dc3 commit e9ace37

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

internal/update/update.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,12 @@ func (u *UpdateNotification) isCI() bool {
223223

224224
// isIgnoredCommand returns true when the process is in the list of commands.
225225
func (u *UpdateNotification) isIgnoredCommand() bool {
226+
// Commands that skip update checks only when used alone or with flags
226227
// "manifest" is included because it's an alias that runs "manifest info"
227-
ignoredCommands := []string{"_fingerprint", "api", "manifest", "manifest info", "version"}
228+
ignoredCommands := []string{"_fingerprint", "manifest", "manifest info", "version"}
229+
// Commands that skip update checks regardless of any arguments
230+
// "api" is a leaf command that accepts positional args, not subcommands
231+
ignoredPrefixes := []string{"api"}
228232
if len(os.Args) < 2 {
229233
return false
230234
}
@@ -246,6 +250,11 @@ func (u *UpdateNotification) isIgnoredCommand() bool {
246250
}
247251
}
248252
}
253+
for _, prefix := range ignoredPrefixes {
254+
if commandStr == prefix || strings.HasPrefix(commandStr, prefix+" ") {
255+
return true
256+
}
257+
}
249258
return false
250259
}
251260

internal/update/update_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ func Test_UpdateNotification_isIgnoredCommand(t *testing.T) {
158158
command: "api",
159159
expected: true,
160160
},
161+
"api command with method": {
162+
command: "api chat.postMessage",
163+
expected: true,
164+
},
165+
"api command with method and args": {
166+
command: "api chat.postMessage channel=C123 text=hello",
167+
expected: true,
168+
},
169+
"api command with flags": {
170+
command: "api chat.postMessage --json {}",
171+
expected: true,
172+
},
161173
"fingerprint command": {
162174
command: "_fingerprint",
163175
expected: true,

0 commit comments

Comments
 (0)