Fix up file reseting

This commit is contained in:
2025-03-26 11:10:43 +01:00
parent 2c7a4f5d97
commit 068c64d714

10
main.go
View File

@@ -270,9 +270,15 @@ func cleanupGitFiles(files []string) error {
logger.Printf("Successfully committed file: %s with message: 'Track %s'", filename, filename)
} else {
logger.Printf("File %s is already tracked. Restoring it to the working tree.", file)
worktree.Restore(&git.RestoreOptions{
Files: []string{file},
err := worktree.Restore(&git.RestoreOptions{
Files: []string{file},
Staged: true,
Worktree: true,
})
if err != nil {
fmt.Fprintf(os.Stderr, "Error restoring file: %v\n", err)
return fmt.Errorf("error restoring file: %w", err)
}
logger.Printf("File %s restored successfully.", file)
}
}