Skip to content

Commit

Permalink
Merge pull request #2 from codecrafters-io/rohitpaulk/git-add-too
Browse files Browse the repository at this point in the history
git add . before committing
  • Loading branch information
rohitpaulk authored Nov 24, 2022
2 parents 81a5f78 + 2a6011c commit bfc0e61
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/commands/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,18 @@ func commitChanges(tmpDir string, commitMessage string) (string, error) {
return "", errors.New("test sentry error")
}

outputBytes, err := exec.Command("git", "-C", tmpDir, "commit", "--allow-empty", "-a", "-m", commitMessage).CombinedOutput()
outputBytes, err := exec.Command("git", "-C", tmpDir, "add", ".").CombinedOutput()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
fmt.Fprintf(os.Stderr, "failed to add all files: %s", outputBytes)
return "", err
} else {
fmt.Fprintf(os.Stderr, "failed to add all files: %s", err)
return "", err
}
}

outputBytes, err = exec.Command("git", "-C", tmpDir, "commit", "--allow-empty", "-a", "-m", commitMessage).CombinedOutput()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
fmt.Fprintf(os.Stderr, "failed to create temp commit: %s", outputBytes)
Expand Down

0 comments on commit bfc0e61

Please sign in to comment.