diff --git a/pkg/cli/update_check.go b/pkg/cli/update_check.go index 9d15533a67a..1bc68e08582 100644 --- a/pkg/cli/update_check.go +++ b/pkg/cli/update_check.go @@ -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) { diff --git a/pkg/cli/update_check_test.go b/pkg/cli/update_check_test.go index fd440b7bab8..ff45cb2c90e 100644 --- a/pkg/cli/update_check_test.go +++ b/pkg/cli/update_check_test.go @@ -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 diff --git a/pkg/console/console.go b/pkg/console/console.go index 868f0c06c33..021a2639ef7 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -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 @@ -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 diff --git a/pkg/console/console_formatting_test.go b/pkg/console/console_formatting_test.go index 883e2803f19..44f7b629e6d 100644 --- a/pkg/console/console_formatting_test.go +++ b/pkg/console/console_formatting_test.go @@ -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"}) @@ -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 diff --git a/pkg/workflow/permissions_factory.go b/pkg/workflow/permissions_factory.go index bcf9ea94202..128a17f52fc 100644 --- a/pkg/workflow/permissions_factory.go +++ b/pkg/workflow/permissions_factory.go @@ -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.