diff --git a/pkg/cli/init.go b/pkg/cli/init.go index 6ae7b73ec4..4289981820 100644 --- a/pkg/cli/init.go +++ b/pkg/cli/init.go @@ -159,16 +159,6 @@ func initializeBasicRepository(verbose bool) error { fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Configured .gitattributes")) } - // Ensure .github/aw/logs/.gitignore exists - initLog.Print("Ensuring .github/aw/logs/.gitignore exists") - if err := ensureLogsGitignore(); err != nil { - initLog.Printf("Failed to ensure logs .gitignore: %v", err) - return fmt.Errorf("failed to ensure logs .gitignore: %w", err) - } - if verbose { - fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Configured .github/aw/logs/.gitignore")) - } - // Write copilot instructions initLog.Print("Writing GitHub Copilot instructions") if err := ensureCopilotInstructions(verbose, false); err != nil { @@ -487,16 +477,6 @@ func InitRepository(verbose bool, mcp bool, tokens bool, engine string, codespac fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Configured .gitattributes")) } - // Ensure .github/aw/logs/.gitignore exists - initLog.Print("Ensuring .github/aw/logs/.gitignore exists") - if err := ensureLogsGitignore(); err != nil { - initLog.Printf("Failed to ensure logs .gitignore: %v", err) - return fmt.Errorf("failed to ensure logs .gitignore: %w", err) - } - if verbose { - fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Configured .github/aw/logs/.gitignore")) - } - // Write copilot instructions initLog.Print("Writing GitHub Copilot instructions") if err := ensureCopilotInstructions(verbose, false); err != nil { diff --git a/pkg/cli/init_command.go b/pkg/cli/init_command.go index 6eb4b0622c..07e59ebdb7 100644 --- a/pkg/cli/init_command.go +++ b/pkg/cli/init_command.go @@ -28,7 +28,6 @@ Interactive Mode (default): This command: - Configures .gitattributes to mark .lock.yml files as generated -- Creates .github/aw/logs/.gitignore to ignore downloaded workflow logs - Creates GitHub Copilot custom instructions at .github/aw/github-agentic-workflows.md - Creates the dispatcher agent at .github/agents/agentic-workflows.agent.md - Creates workflow creation prompt at .github/aw/create-agentic-workflow.md (for new workflows) diff --git a/pkg/cli/init_command_test.go b/pkg/cli/init_command_test.go index bb035ac8e5..8f3ad22467 100644 --- a/pkg/cli/init_command_test.go +++ b/pkg/cli/init_command_test.go @@ -217,12 +217,6 @@ func TestInitRepositoryBasic(t *testing.T) { t.Errorf("Expected .gitattributes to contain %q", expectedEntry) } - // Verify logs .gitignore was created - logsGitignorePath := filepath.Join(".github", "aw", "logs", ".gitignore") - if _, err := os.Stat(logsGitignorePath); os.IsNotExist(err) { - t.Error("Expected .github/aw/logs/.gitignore to be created") - } - // Verify MCP files were created by default mcpConfigPath := filepath.Join(".vscode", "mcp.json") if _, err := os.Stat(mcpConfigPath); os.IsNotExist(err) { diff --git a/pkg/cli/init_test.go b/pkg/cli/init_test.go index 9db7c7ed54..2c5e1886de 100644 --- a/pkg/cli/init_test.go +++ b/pkg/cli/init_test.go @@ -76,30 +76,8 @@ func TestInitRepository(t *testing.T) { t.Errorf("Expected .gitattributes file to exist") } - // Note: The following files are NOT created by init - they are source of truth in .github/aw/ - // and should already exist in the gh-aw repository itself - - // Verify logs .gitignore was created - logsGitignorePath := filepath.Join(tempDir, ".github", "aw", "logs", ".gitignore") - if _, err := os.Stat(logsGitignorePath); os.IsNotExist(err) { - t.Errorf("Expected .github/aw/logs/.gitignore file to exist") - } - - // Verify logs .gitignore content - if content, err := os.ReadFile(logsGitignorePath); err == nil { - contentStr := string(content) - if !strings.Contains(contentStr, "# Ignore all downloaded workflow logs") { - t.Errorf("Expected .gitignore to contain comment about ignoring logs") - } - if !strings.Contains(contentStr, "*") { - t.Errorf("Expected .gitignore to contain wildcard pattern") - } - if !strings.Contains(contentStr, "!.gitignore") { - t.Errorf("Expected .gitignore to keep itself") - } - } else { - t.Errorf("Failed to read .github/aw/logs/.gitignore: %v", err) - } + // Note: The .github/aw/logs/.gitignore file is no longer created by init. + // It is now created by the logs download command on every invocation. // Verify .gitattributes contains the correct entry content, err := os.ReadFile(gitAttributesPath) @@ -153,15 +131,8 @@ func TestInitRepository_Idempotent(t *testing.T) { t.Errorf("Expected .gitattributes file to exist after second call") } - // Note: The following files are NOT created by init - they are source of truth in .github/aw/ - // and should already exist in the gh-aw repository itself. These tests are not relevant - // for external repositories. - - // Verify logs .gitignore still exists after second call - logsGitignorePath := filepath.Join(tempDir, ".github", "aw", "logs", ".gitignore") - if _, err := os.Stat(logsGitignorePath); os.IsNotExist(err) { - t.Errorf("Expected .github/aw/logs/.gitignore file to exist after second call") - } + // Note: The .github/aw/logs/.gitignore file is no longer created by init. + // It is now created by the logs download command on every invocation. } func TestInitRepository_Verbose(t *testing.T) { diff --git a/pkg/cli/logs_orchestrator.go b/pkg/cli/logs_orchestrator.go index c55ecf2c5f..efa655b031 100644 --- a/pkg/cli/logs_orchestrator.go +++ b/pkg/cli/logs_orchestrator.go @@ -43,6 +43,15 @@ func getMaxConcurrentDownloads() int { func DownloadWorkflowLogs(ctx context.Context, workflowName string, count int, startDate, endDate, outputDir, engine, ref string, beforeRunID, afterRunID int64, repoOverride string, verbose bool, toolGraph bool, noStaged bool, firewallOnly bool, noFirewall bool, parse bool, jsonOutput bool, timeout int, summaryFile string, safeOutputType string) error { logsOrchestratorLog.Printf("Starting workflow log download: workflow=%s, count=%d, startDate=%s, endDate=%s, outputDir=%s, summaryFile=%s, safeOutputType=%s", workflowName, count, startDate, endDate, outputDir, summaryFile, safeOutputType) + // Ensure .github/aw/logs/.gitignore exists on every invocation + if err := ensureLogsGitignore(); err != nil { + // Log but don't fail - this is not critical for downloading logs + logsOrchestratorLog.Printf("Failed to ensure logs .gitignore: %v", err) + if verbose { + fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to ensure .github/aw/logs/.gitignore: %v", err))) + } + } + // Check context cancellation at the start select { case <-ctx.Done():