Skip to content

Commit 005a919

Browse files
committed
fix: ci.yml, pr.go
1 parent fc82501 commit 005a919

2 files changed

Lines changed: 50 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ jobs:
287287
git config --global user.email "actions@github.com"
288288
git config --global user.name "GitHub Actions"
289289
290-
- name: Create Test Files
290+
- name: Create Test Files and Add to Git
291291
run: |
292292
# 테스트 디렉토리 생성
293293
mkdir -p test/multi-pattern
@@ -299,8 +299,11 @@ jobs:
299299
echo "Test file 3 - $(date +%s)" > file3.json
300300
echo "Test file 4 - $(date +%s)" > file4.txt
301301
302-
# 디렉토리 내용 확인
302+
# 파일 확인
303+
echo "디렉토리 내용:"
303304
ls -la
305+
306+
# 경로 돌아가기
304307
cd ../..
305308
306309
- name: Test Commit with Multiple File Pattern (space separated)
@@ -335,7 +338,7 @@ jobs:
335338
branch: test
336339
repository_path: "./test/multi-pattern"
337340
file_pattern: "file3.json file4.txt"
338-
341+
339342
- name: Verify Second Pattern
340343
run: |
341344
git log -1 --name-status
@@ -359,6 +362,7 @@ jobs:
359362
with:
360363
fetch-depth: 10
361364
token: ${{ secrets.PAT_TOKEN }}
365+
ref: test
362366

363367
- name: Configure Git Safe Directory
364368
run: git config --global --add safe.directory ${{ github.workspace }}
@@ -368,10 +372,15 @@ jobs:
368372
git config --global user.email "actions@github.com"
369373
git config --global user.name "GitHub Actions"
370374
371-
- name: Create Test File for PR
372-
run: |
375+
- name: Create Test File for PR and Add to Git
376+
run: |
377+
mkdir -p test
373378
echo "Test file for PR dry run - $(date +%s)" > test/pr-dry-run-test.txt
374-
379+
380+
# 파일 확인
381+
echo "생성된 PR 테스트 파일:"
382+
ls -la test/
383+
375384
- name: Test PR Dry Run (auto_branch false)
376385
uses: ./
377386
with:
@@ -388,7 +397,7 @@ jobs:
388397
file_pattern: "pr-dry-run-test.txt"
389398
github_token: ${{ secrets.PAT_TOKEN }}
390399
pr_dry_run: true
391-
400+
392401
- name: Test PR Dry Run (auto_branch true)
393402
uses: ./
394403
with:

internal/git/pr.go

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,48 @@ func prepareSourceBranch(config *config.GitConfig) (string, error) {
115115

116116
// commitAndPushChanges commits and pushes changes.
117117
func 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

Comments
 (0)