@@ -115,17 +115,48 @@ func prepareSourceBranch(config *config.GitConfig) (string, error) {
115115
116116// commitAndPushChanges commits and pushes changes.
117117func commitAndPushChanges (config * config.GitConfig ) error {
118- commitCommands := []struct {
118+ // Handle git add with file pattern that may contain spaces
119+ fmt .Printf (" • Adding files... " )
120+
121+ // Check if file pattern contains spaces, indicating multiple files/patterns
122+ if strings .Contains (config .FilePattern , " " ) {
123+ // Split the pattern and add each file/pattern individually
124+ patterns := strings .Fields (config .FilePattern )
125+ for _ , pattern := range patterns {
126+ addCmd := exec .Command ("git" , "add" , pattern )
127+ addCmd .Stdout = os .Stdout
128+ addCmd .Stderr = os .Stderr
129+
130+ if err := addCmd .Run (); err != nil {
131+ fmt .Println ("❌ Failed" )
132+ return fmt .Errorf ("failed to add pattern %s: %v" , pattern , err )
133+ }
134+ }
135+ fmt .Println ("✅ Done" )
136+ } else {
137+ // Single file pattern case - proceed as before
138+ addCmd := exec .Command ("git" , "add" , config .FilePattern )
139+ addCmd .Stdout = os .Stdout
140+ addCmd .Stderr = os .Stderr
141+
142+ if err := addCmd .Run (); err != nil {
143+ fmt .Println ("❌ Failed" )
144+ return fmt .Errorf ("failed to add files: %v" , err )
145+ }
146+ fmt .Println ("✅ Done" )
147+ }
148+
149+ // Continue with commit and push commands
150+ commitPushCommands := []struct {
119151 name string
120152 args []string
121153 desc string
122154 }{
123- {"git" , []string {"add" , config .FilePattern }, "Adding files" },
124155 {"git" , []string {"commit" , "-m" , config .CommitMessage }, "Committing changes" },
125156 {"git" , []string {"push" , "-u" , "origin" , config .PRBranch }, "Pushing changes" },
126157 }
127158
128- for _ , cmd := range commitCommands {
159+ for _ , cmd := range commitPushCommands {
129160 fmt .Printf (" • %s... " , cmd .desc )
130161 command := exec .Command (cmd .name , cmd .args ... )
131162 command .Stdout = os .Stdout
0 commit comments