Skip to content

Passing -a or --commit-all parameter doesn't commit all files #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
viljuska opened this issue Apr 2, 2025 · 8 comments · May be fixed by #219
Open

Passing -a or --commit-all parameter doesn't commit all files #217

viljuska opened this issue Apr 2, 2025 · 8 comments · May be fixed by #219
Labels
bug Something isn't working

Comments

@viljuska
Copy link

viljuska commented Apr 2, 2025

Describe the bug
There is an option to commit all tracked files on git by passing parameter -a or --commit-all, but it doesn't work. While inspecting the code, I noticed that in commit.js file when option commitAll is true, it passes empty string while it should either add dot (.) or -A to git commit.

Current behavior
It doesn't commit all files when passing option -a/--commit-all

Expected behavior
It should commit all files when passing option -a/--commit-all

Environment

  • commit-and-tag-version version(s): 12.5.0
  • Node/npm version: 22.12.0/10.9.0
  • OS: macOS 15.3.2

Possible Solution

I tried changing this line to add a dot (.) and it commited all files then:
await runExecFile(
args,
'git',
['commit'].concat(verify, sign, signoff, args.commitAll ? ['.'] : toAdd, [
'-m',
${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)},
]),
);

@viljuska viljuska added the bug Something isn't working label Apr 2, 2025
@SeraphCoding
Copy link

Has been broken since at least 12.0.0

@SeraphCoding
Copy link

SeraphCoding commented Apr 7, 2025

Repo seems a little bit inactive. Dropping a very friendly @ ^^
@TimothyJones Could you take a quick look at the PR I've created?

I think this should fix it if @viljuska 's solution is correct.

@SeraphCoding SeraphCoding linked a pull request Apr 7, 2025 that will close this issue
@TimothyJones
Copy link
Member

Hi, I'm travelling at the moment, apologies for the slow response. PR looks fine to me

@TimothyJones
Copy link
Member

Double checking the documentation it looks to me like it's not supposed to commit all files - it's supposed to commit whatever was staged.

Are you saying we should change this?

@SeraphCoding
Copy link

@TimothyJones
Quite frankly I've stumbled upon this issue looking for a solution of my own problem and decided to provide a quick PR for it, cuz it seems to be quite simple.

Yknow, giving a little bit back :D

In regards to your question - going by the documentation you're right. Perhaps having a separate option to not only commit what was staged but just everything in general could be considered?

Though in that situation one may as well just stage everything first and then commit it all with existing tools.

@TimothyJones
Copy link
Member

Ah, makes sense. I think a commit all option would be convenient, but also might be a bit of a footgun (since the existing behaviour of committing only what was explicitly staged would prevent people from accidentally including things they didn't mean to).

Perhaps an option that commits everything (but with a warning documented about using it) could be added?

@SeraphCoding
Copy link

Though that would likely introduce a breaking change as "commit all" would become "commit all staged" (as it is right now) and then a true "commit all" would be added.

I'll try to find the time to adjust my existing PR.

@TimothyJones
Copy link
Member

TimothyJones commented Apr 27, 2025

I don't think that's a breaking change - "commit all" has always been "commit all staged", we'd just be adding "stage and commit all" (as a new parameter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants