From 79fcce934f96e4d32c2e4715a4b3d4a5592cd161 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 01:37:27 +0000 Subject: [PATCH 1/5] Initial plan From 207c3b8dad6a16c59a03c9ecf22ce39c85e49990 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 01:41:05 +0000 Subject: [PATCH 2/5] Add .github/aw/.gitignore to ignore imports folder Agent-Logs-Url: https://github.com/github/gh-aw/sessions/70a5afc2-e75a-43a8-8423-18542e9b9004 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/aw/.gitignore diff --git a/.github/aw/.gitignore b/.github/aw/.gitignore new file mode 100644 index 00000000000..a7fe32e7e32 --- /dev/null +++ b/.github/aw/.gitignore @@ -0,0 +1 @@ +imports/ From da7e16ad0a05ab0627b97fac22749ff4c57384a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 01:52:58 +0000 Subject: [PATCH 3/5] Add ensureAwGitignore to init command to create .github/aw/.gitignore with imports/ entry Agent-Logs-Url: https://github.com/github/gh-aw/sessions/25ad36e8-2a03-47e9-ad53-c7f4f06cf236 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/git.go | 34 ++++++++++++++++++++++++++++++++++ pkg/cli/init.go | 10 ++++++++++ 2 files changed, 44 insertions(+) diff --git a/pkg/cli/git.go b/pkg/cli/git.go index 0ca4c85b406..14c0be702a3 100644 --- a/pkg/cli/git.go +++ b/pkg/cli/git.go @@ -334,6 +334,40 @@ func ensureLogsGitignore() error { return nil } +// ensureAwGitignore ensures that .github/aw/.gitignore exists and contains the imports/ entry +func ensureAwGitignore() error { + gitLog.Print("Ensuring .github/aw/.gitignore exists") + gitRoot, err := findGitRoot() + if err != nil { + return err + } + + awDir := filepath.Join(gitRoot, ".github", "aw") + gitignorePath := filepath.Join(awDir, ".gitignore") + + // Check if .gitignore already exists + if _, err := os.Stat(gitignorePath); err == nil { + gitLog.Print(".github/aw/.gitignore already exists") + return nil + } + + gitLog.Print("Creating .github/aw directory and .gitignore") + if err := os.MkdirAll(awDir, 0755); err != nil { + gitLog.Printf("Failed to create .github/aw directory: %v", err) + return fmt.Errorf("failed to create .github/aw directory: %w", err) + } + + gitignoreContent := `imports/ +` + if err := os.WriteFile(gitignorePath, []byte(gitignoreContent), 0600); err != nil { + gitLog.Printf("Failed to write .gitignore: %v", err) + return fmt.Errorf("failed to write .github/aw/.gitignore: %w", err) + } + + gitLog.Print("Successfully created .github/aw/.gitignore") + return nil +} + // getCurrentBranch gets the current git branch name func getCurrentBranch() (string, error) { gitLog.Print("Getting current git branch") diff --git a/pkg/cli/init.go b/pkg/cli/init.go index 21cb5453b3e..dcd7aa50cf4 100644 --- a/pkg/cli/init.go +++ b/pkg/cli/init.go @@ -58,6 +58,16 @@ func InitRepository(opts InitOptions) error { fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Configured .gitattributes")) } + // Ensure .github/aw/.gitignore exists with imports/ entry + initLog.Print("Ensuring .github/aw/.gitignore exists") + if err := ensureAwGitignore(); err != nil { + initLog.Printf("Failed to ensure .github/aw/.gitignore: %v", err) + return fmt.Errorf("failed to ensure .github/aw/.gitignore: %w", err) + } + if opts.Verbose { + fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Ensured .github/aw/.gitignore")) + } + // Write dispatcher agent initLog.Print("Writing agentic workflows dispatcher agent") if err := ensureAgenticWorkflowsDispatcher(opts.Verbose, false); err != nil { From be31b048f116ee115839bbbb49b16b40afe018ac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 02:00:21 +0000 Subject: [PATCH 4/5] Also gitignore logs/ folder in .github/aw/.gitignore and update ensureAwGitignore to handle existing files Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c345bb70-3331-45ec-b4b1-65cba155911a Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/.gitignore | 1 + pkg/cli/git.go | 56 +++++++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/.github/aw/.gitignore b/.github/aw/.gitignore index a7fe32e7e32..481353f54b3 100644 --- a/.github/aw/.gitignore +++ b/.github/aw/.gitignore @@ -1 +1,2 @@ imports/ +logs/ diff --git a/pkg/cli/git.go b/pkg/cli/git.go index 14c0be702a3..0d8b2b5adf7 100644 --- a/pkg/cli/git.go +++ b/pkg/cli/git.go @@ -334,7 +334,11 @@ func ensureLogsGitignore() error { return nil } -// ensureAwGitignore ensures that .github/aw/.gitignore exists and contains the imports/ entry +// awGitignoreEntries lists all entries that must be present in .github/aw/.gitignore. +var awGitignoreEntries = []string{"imports/", "logs/"} + +// ensureAwGitignore ensures that .github/aw/.gitignore exists and contains the required entries. +// If the file already exists, any missing entries are appended. func ensureAwGitignore() error { gitLog.Print("Ensuring .github/aw/.gitignore exists") gitRoot, err := findGitRoot() @@ -345,26 +349,54 @@ func ensureAwGitignore() error { awDir := filepath.Join(gitRoot, ".github", "aw") gitignorePath := filepath.Join(awDir, ".gitignore") - // Check if .gitignore already exists - if _, err := os.Stat(gitignorePath); err == nil { - gitLog.Print(".github/aw/.gitignore already exists") - return nil - } - - gitLog.Print("Creating .github/aw directory and .gitignore") if err := os.MkdirAll(awDir, 0755); err != nil { gitLog.Printf("Failed to create .github/aw directory: %v", err) return fmt.Errorf("failed to create .github/aw directory: %w", err) } - gitignoreContent := `imports/ -` - if err := os.WriteFile(gitignorePath, []byte(gitignoreContent), 0600); err != nil { + // Read existing content (if any) + existing, readErr := os.ReadFile(gitignorePath) + existingContent := "" + if readErr == nil { + existingContent = string(existing) + gitLog.Print(".github/aw/.gitignore already exists, checking for missing entries") + } + + // Collect any entries that are not yet present + var missing []string + for _, entry := range awGitignoreEntries { + if !strings.Contains(existingContent, entry) { + missing = append(missing, entry) + } + } + + if len(missing) == 0 { + gitLog.Print(".github/aw/.gitignore already contains all required entries") + return nil + } + + // Append missing entries (ensure file ends with a newline before appending) + appendContent := "" + if existingContent != "" && !strings.HasSuffix(existingContent, "\n") { + appendContent = "\n" + } + for _, entry := range missing { + appendContent += entry + "\n" + } + + f, err := os.OpenFile(gitignorePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) + if err != nil { + gitLog.Printf("Failed to open .gitignore for writing: %v", err) + return fmt.Errorf("failed to write .github/aw/.gitignore: %w", err) + } + defer f.Close() + + if _, err := f.WriteString(appendContent); err != nil { gitLog.Printf("Failed to write .gitignore: %v", err) return fmt.Errorf("failed to write .github/aw/.gitignore: %w", err) } - gitLog.Print("Successfully created .github/aw/.gitignore") + gitLog.Printf("Successfully updated .github/aw/.gitignore (added: %v)", missing) return nil } From 25a8c0056f162d7e21a92c18c7fba9ae853c6181 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 10:39:13 +0000 Subject: [PATCH 5/5] =?UTF-8?q?Remove=20duplicate=20logs/=20from=20.github?= =?UTF-8?q?/aw/.gitignore=20=E2=80=94=20ensureLogsGitignore=20already=20ha?= =?UTF-8?q?ndles=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/github/gh-aw/sessions/02e89237-8e68-459a-80fa-17ad165a0851 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/.gitignore | 1 - pkg/cli/git.go | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/aw/.gitignore b/.github/aw/.gitignore index 481353f54b3..a7fe32e7e32 100644 --- a/.github/aw/.gitignore +++ b/.github/aw/.gitignore @@ -1,2 +1 @@ imports/ -logs/ diff --git a/pkg/cli/git.go b/pkg/cli/git.go index 0d8b2b5adf7..fd0b81f6b3c 100644 --- a/pkg/cli/git.go +++ b/pkg/cli/git.go @@ -335,7 +335,9 @@ func ensureLogsGitignore() error { } // awGitignoreEntries lists all entries that must be present in .github/aw/.gitignore. -var awGitignoreEntries = []string{"imports/", "logs/"} +// Note: the logs/ directory is handled separately by ensureLogsGitignore() which creates +// .github/aw/logs/.gitignore so that the directory itself remains tracked by git. +var awGitignoreEntries = []string{"imports/"} // ensureAwGitignore ensures that .github/aw/.gitignore exists and contains the required entries. // If the file already exists, any missing entries are appended.