koji icon indicating copy to clipboard operation
koji copied to clipboard

The behavior when there are no files in the staging area.

Open ryo246912 opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

When executed with no files in the staging area, interactive questions are displayed despite there being no files to commit, and after answering all questions, the commit fails with an error.

Describe the solution you'd like

I would like koji to exit early before displaying interactive questions when executed with no files in the staging area. This would help users recognize mistakes earlier and prevent the unnecessary effort of re-answering their questions.

Describe alternatives you've considered

None.

Additional context

This is an excellent tool! I would love to use it actively and have a few requests. I usually use czg, and I think koji could become an even more attractive tool by referencing some of its features.

in czg, if there are no files in the staging area, it exits early with the following behavior:

~/.local/share/chezmoi % git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   dot_zshrc.lazy.tmpl

no changes added to commit (use "git add" and/or "git commit -a")

~/.local/share/chezmoi % koji
> What type of change are you committing? feat
> What's the scope of this change?
> Write a short, imperative tense description of the change: x
> Provide a longer description of the change:
> Are there any breaking changes? No
> Does this change affect any open issues? No
Error: On branch main

Untracked files :
        modified: dot_zshrc.lazy.tmpl

nothing added to commit but untracked files present (use "git add" to track)

~/.local/share/chezmoi % czg
>>> No files added to staging! Did you forget to run `git add` ?

~/.local/share/chezmoi % 

ryo246912 avatar Jan 10 '25 10:01 ryo246912

I agree, it's quite frustrating when you forget to add files first.

Also I maybe would add an option to handle this behaviour to either abort or to automatically add all files to the staging area.

veeso avatar Mar 17 '25 08:03 veeso