Skip to content

Fix crash when staging deleted files during commit confirmation #85

@thomas-vilte

Description

@thomas-vilte

Description

I encountered a critical error when attempting to commit changes involving a deleted file. The tool attempts to stage the specific file path directly, which results in a failure because the file no longer exists on the filesystem. The logic should handle file deletions gracefully rather than attempting to add a non-existent file.

Reproduction Steps

  1. Delete a tracked file from the repository (e.g., rm internal/errores/aws_errors.go).
  2. Run the commit suggestion command.
  3. When prompted with "Confirm commit? (y/n)", select "y".

Expected Behavior

I expected the tool to detect that the file was deleted and stage the deletion correctly (similar to git add -u or git rm), allowing the commit process to proceed without errors.

Actual Behavior

The CLI crashed with an error indicating it could not add the file to staging because the file does not exist.

Version

Latest

Additional Context

[ERROR] file does not exist file=internal/errores/aws_errors.go full_path=/home/enano/elytra/internal/errores/aws_errors.go
[ERROR] failed to stage file file=internal/errores/aws_errors.go error=GIT: Failed to add file to staging (stat /home/enano/elytra/internal/errores/aws_errors.go: no such file or directory)
❌ Error adding file internal/errores/aws_errors.go to staging, due to: GIT: Failed to add file to staging (stat /home/enano/elytra/internal/errores/aws_errors.go: no such file or directory)
[ERROR] failed to handle commit selection error=error adding internal/errores/aws_errors.go: GIT: Failed to add file to staging (stat /home/enano/elytra/internal/errores/aws_errors.go: no such file or directory)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as it should.fixBug fixesgoPull requests that update go codegood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions