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
git cz -a just differently broken now #543
Comments
Okay, here are some repro steps and a possible solution (though I don't know enough about how other people use Git to know if there are any ramifications to my approach): Repro:~/Sites/spikes/cz-cli
12:15:00 $ git init && yarn init -y
Initialized empty Git repository in ~/Sites/spikes/cz-cli/.git/
yarn init v1.7.0
warning The yes flag has been set. This will automatically answer yes to all questions, which may have security implications.
success Saved package.json
✨ Done in 0.11s.
~/Sites/spikes/cz-cli (master #%)
12:15:50 $ git add package.json
~/Sites/spikes/cz-cli (master +)
12:15:57 $ git commit -am "chore: git init && yarn init -y"
[master (root-commit) 14cad29] chore: git init && yarn init -y
1 file changed, 7 insertions(+)
create mode 100644 package.json
~/Sites/spikes/cz-cli (master)
12:15:58 $ echo "node_modules" > .gitignore
~/Sites/spikes/cz-cli (master %)
12:16:18 $ git add .gitignore
~/Sites/spikes/cz-cli (master +)
12:16:25 $ git commit -am "chore: ignore node_modules"
[master b583ffa] chore: ignore node_modules
1 file changed, 1 insertion(+)
create mode 100644 .gitignore
~/Sites/spikes/cz-cli (master)
12:16:43 $ yarn add -D commitizen cz-conventional-changelog
# =======================================
# REMOVED YARN LOGS FOR SPACE
# =======================================
~/Sites/spikes/cz-cli (master *%)
12:17:33 $ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: package.json
Untracked files:
(use "git add <file>..." to include in what will be committed)
yarn.lock
no changes added to commit (use "git add" and/or "git commit -a")
~/Sites/spikes/cz-cli (master *%)
12:17:38 $ git add yarn.lock
~/Sites/spikes/cz-cli (master +)
12:17:44 $ git commit -am "chore: add commitizen and cz-conventional-changelog to dev-deps"
[master ad04fc9] chore: add commitizen and cz-conventional-changelog to dev-deps
2 files changed, 963 insertions(+), 1 deletion(-)
create mode 100644 yarn.lock
# =======================================
# ADD COMMITIZEN CONFIG TO PACKAGE.JSON
# =======================================
~/Sites/spikes/cz-cli (master)
12:18:06 $ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")
~/Sites/spikes/cz-cli (master *)
12:19:24 $ git diff
diff --git a/package.json b/package.json
index 97b6eb9..91fef3d 100644
--- a/package.json
+++ b/package.json
@@ -7,5 +7,10 @@
"devDependencies": {
"commitizen": "^2.10.1",
"cz-conventional-changelog": "^2.1.0"
+ },
+ "config": {
+ "commitizen": {
+ "path": "cz-conventional-changelog"
+ }
}
}
~/Sites/spikes/cz-cli (master *)
12:19:25 $ git commit -am "config: add commitizen config to package.json"
[master 2c2d272] config: add commitizen config to package.json
1 file changed, 5 insertions(+)
~/Sites/spikes/cz-cli (master)
12:19:50 $ touch foo.txt
~/Sites/spikes/cz-cli (master %)
12:20:05 $ git add foo.txt
~/Sites/spikes/cz-cli (master +)
12:20:17 $ git commit -am "feat: foo.txt"
[master d2b899c] feat: foo.txt
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo.txt
~/Sites/spikes/cz-cli (master)
12:20:23 $ echo "bar" > foo.txt
~/Sites/spikes/cz-cli (master *)
12:20:32 $ git diff
diff --git a/foo.txt b/foo.txt
index e69de29..5716ca5 100644
--- a/foo.txt
+++ b/foo.txt
@@ -0,0 +1 @@
+bar
~/Sites/spikes/cz-cli (master *)
12:20:36 $ git cz -a
No files added to staging! Did you forget to run git add?
~/Sites/spikes/cz-cli (master *)
12:20:42 $ git commit -am "feat: add bar to foo.txt"
[master a4e286e] feat: add bar to foo.txt
1 file changed, 1 insertion(+) I think the problem is here src/commitizen/staging.js#L9 … ~/Sites/spikes/cz-cli (master)
12:21:01 $ touch baz.txt
~/Sites/spikes/cz-cli (master %)
12:31:20 $ echo "qux" > foo.txt
~/Sites/spikes/cz-cli (master *%)
12:31:29 $ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: foo.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
baz.txt
no changes added to commit (use "git add" and/or "git commit -a")
~/Sites/spikes/cz-cli (master *%)
12:31:32 $ git diff --cached --name-only
~/Sites/spikes/cz-cli (master *%)
12:32:02 $ git diff --name-only
foo.txt Without the ✨❤️🌟 |
@mysterycommand not sure if your suggestion will work with "manually added files", like with |
I made a PR. I am not used to contributing but I did my best… 🙏 |
Hey @thierrymichel, ugh! you're right … doing something like this demonstrates that my solution doesn't work when the commit would contain only new files: $ touch foo.txt
$ touch bar.txt
$ git add foo.txt
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: foo.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
bar.txt
$ git diff --name-only
$ git diff --cached --name-only
staging.js
$ git cz
No files added to staging! Did you forget to run git add?
$ git cz -a
No files added to staging! Did you forget to run git add? 😭 As for your PR, I'd be kind of hesitant to add that
I have an idea that borrows from $ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: baz.txt
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: foo.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
bar.txt
$ git diff --no-ext-diff --name-only && git diff --no-ext-diff --cached --name-only
foo.txt
baz.txt So, I think if instead of |
@mysterycommand easier and cleverer (and working)! 👍 |
Hello there, thanks for this project. I've really enjoyed getting changelogs out of my commit messages. I think a recent change to
git cz -a
(to fix a perhaps over exuberantgit add .
) has unfortunately just broken things differently. It's late where I am, so I'll have to try and come up with an example repo tomorrow, but I'm currently running into an issue where I get the following output in a terminal:So, it seems to me something is still not quite right with the
-a
flag. Thanks again for your help. I'll be happy to try and test out any steps anyone might recommend for me.The text was updated successfully, but these errors were encountered: