Skip to content
Merged
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
6 changes: 0 additions & 6 deletions pkg/cli/update_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ func updateLastCheckTime() {
writeUpdateCheckTime(getLastCheckFilePath(), constants.FilePermPublic, "update check", updateCheckLog)
}

// checkForUpdates checks if a newer version of gh-aw is available
// This function is non-blocking and ignores all errors (connectivity, API, etc.)
func checkForUpdates(noCheckUpdate bool, verbose bool) {
checkForUpdatesWithContext(context.Background(), noCheckUpdate, verbose)
}

func checkForUpdatesWithContext(ctx context.Context, noCheckUpdate bool, verbose bool) {
// Quick check if we should even attempt the update check
if !shouldCheckForUpdate(noCheckUpdate) {
Expand Down
81 changes: 0 additions & 81 deletions pkg/cli/update_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,87 +230,6 @@ func TestUpdateLastCheckTime(t *testing.T) {
}
}

func TestCheckForUpdatesWithNoCheckUpdateFlag(t *testing.T) {
// This test verifies that checkForUpdates respects the noCheckUpdate flag
// and doesn't make any API calls when the flag is true

// Save original environment and function
origCI := os.Getenv("CI")
origGithubActions := os.Getenv("GITHUB_ACTIONS")
origContinuousIntegration := os.Getenv("CONTINUOUS_INTEGRATION")
origGetLastCheckFilePath := getLastCheckFilePathFunc
defer func() {
if origCI != "" {
os.Setenv("CI", origCI)
} else {
os.Unsetenv("CI")
}
if origGithubActions != "" {
os.Setenv("GITHUB_ACTIONS", origGithubActions)
} else {
os.Unsetenv("GITHUB_ACTIONS")
}
if origContinuousIntegration != "" {
os.Setenv("CONTINUOUS_INTEGRATION", origContinuousIntegration)
} else {
os.Unsetenv("CONTINUOUS_INTEGRATION")
}
getLastCheckFilePathFunc = origGetLastCheckFilePath
}()

// Ensure we're not in CI mode
os.Unsetenv("CI")
os.Unsetenv("GITHUB_ACTIONS")
os.Unsetenv("CONTINUOUS_INTEGRATION")

// Create temporary directory for last check file
tmpDir := t.TempDir()
lastCheckFile := filepath.Join(tmpDir, lastCheckFileName)

// Override the function to use temp directory
getLastCheckFilePathFunc = func() string {
return lastCheckFile
}

// Call checkForUpdates with noCheckUpdate=true
checkForUpdates(true, false)

// Verify that no last check file was created (since check was skipped)
if _, err := os.Stat(lastCheckFile); err == nil {
t.Error("Last check file should not be created when noCheckUpdate=true")
}
}

func TestCheckForUpdatesInCIMode(t *testing.T) {
// Save original environment and function
origCI := os.Getenv("CI")
origGetLastCheckFilePath := getLastCheckFilePathFunc
defer func() {
os.Setenv("CI", origCI)
getLastCheckFilePathFunc = origGetLastCheckFilePath
}()

// Set CI environment
os.Setenv("CI", "true")

// Create temporary directory for last check file
tmpDir := t.TempDir()
lastCheckFile := filepath.Join(tmpDir, lastCheckFileName)

// Override the function to use temp directory
getLastCheckFilePathFunc = func() string {
return lastCheckFile
}

// Call checkForUpdates
checkForUpdates(false, false)

// Verify that no last check file was created (since check was skipped in CI)
if _, err := os.Stat(lastCheckFile); err == nil {
t.Error("Last check file should not be created in CI mode")
}
}

func TestCheckForUpdatesAsync_ContextCancellation(t *testing.T) {
// Test that async update check respects context cancellation
origGetLastCheckFilePath := getLastCheckFilePathFunc
Expand Down
8 changes: 0 additions & 8 deletions pkg/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ func FormatTableHeaderStderr(text string) string {
return applyStderrStyle(styles.TableHeader, text)
}

func formatTableHeaderWithTTY(text string, ttyCheck func() bool) string {
return applyStyleWithTTY(styles.TableHeader, text, ttyCheck)
}

// FormatWarningMessage formats a warning message
func FormatWarningMessage(message string) string {
return applyStyle(styles.Warning, "⚠ ") + message
Expand Down Expand Up @@ -389,10 +385,6 @@ func FormatErrorTextStderr(text string) string {
return applyStderrStyle(styles.Error, text)
}

func formatErrorTextWithTTY(text string, ttyCheck func() bool) string {
return applyStyleWithTTY(styles.Error, text, ttyCheck)
}

// FormatErrorChain formats an error and its full unwrapped chain in a reading-friendly way.
// For wrapped errors (fmt.Errorf with %w), each level of the chain is shown on a new
// indented line. For errors whose message contains newlines (e.g. errors.Join), each
Expand Down
34 changes: 0 additions & 34 deletions pkg/console/console_formatting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,23 +286,6 @@ func TestFormatErrorMessage(t *testing.T) {
}
}

func TestFormatTableHeaderWithTTY(t *testing.T) {
t.Run("plain text when not tty", func(t *testing.T) {
result := formatTableHeaderWithTTY("Header", func() bool { return false })
if result != "Header" {
t.Fatalf("formatTableHeaderWithTTY() = %q, want %q", result, "Header")
}
})

t.Run("styled text when tty", func(t *testing.T) {
result := formatTableHeaderWithTTY("Header", func() bool { return true })
expected := styles.TableHeader.Render("Header")
if result != expected {
t.Fatalf("formatTableHeaderWithTTY() = %q, want %q", result, expected)
}
})
}

func TestApplyStderrStyleWithTTY(t *testing.T) {
t.Run("plain text when stderr is not tty", func(t *testing.T) {
result := applyStderrStyleWithTTY(styles.Warning, "warning", func() bool { return false }, []string{"TERM=xterm-256color"})
Expand Down Expand Up @@ -350,23 +333,6 @@ func TestFormatErrorStderrWithTTY(t *testing.T) {
}
}

func TestFormatErrorTextWithTTY(t *testing.T) {
t.Run("plain text when not tty", func(t *testing.T) {
result := formatErrorTextWithTTY("boom", func() bool { return false })
if result != "boom" {
t.Fatalf("formatErrorTextWithTTY() = %q, want %q", result, "boom")
}
})

t.Run("styled text when tty", func(t *testing.T) {
result := formatErrorTextWithTTY("boom", func() bool { return true })
expected := styles.Error.Render("boom")
if result != expected {
t.Fatalf("formatErrorTextWithTTY() = %q, want %q", result, expected)
}
})
}

func TestFormatSectionHeader(t *testing.T) {
tests := []struct {
name string
Expand Down
10 changes: 0 additions & 10 deletions pkg/workflow/permissions_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,6 @@ func NewPermissionsChecksWritePRRead() *Permissions {
})
}

// NewPermissionsIssuesWriteDiscussionsWritePRWrite creates permissions with issues: write, discussions: write,
// and pull-requests: write.
func NewPermissionsIssuesWriteDiscussionsWritePRWrite() *Permissions {
return NewPermissionsFromMap(map[PermissionScope]PermissionLevel{
PermissionIssues: PermissionWrite,
PermissionDiscussions: PermissionWrite,
PermissionPullRequests: PermissionWrite,
})
}

// NewPermissionsOrganizationProjWriteIssuesRead creates permissions with organization-projects: write
// and issues: read. Used for project-management handlers (update-project, create-project) that read
// issue metadata when adding items to projects.
Expand Down
Loading