Comments (14)
Is it possible to have the commitizen dialogue load when using git cz --amend
?
from cz-cli.
And surprisingly, giz-cz -a
does work...
from cz-cli.
Hi @sebastienbarre. Good question. This is unfortunately a bug.
I looked at it quickly and it seems that the editor that opens when using --amend wants to take the context of the cli. Commitizen will not give up the context due to the way commitizen interacts with git using gulp-git so you get this error. We could implement a really dirty solution that looks for --amend in the string I'm not sure that we want to go that route.
Git-gulp uses require('child_process').exec;
I'd love to be able to use require('child_process').spawn; but, I could not figure out how to both wrap the output and provide useful errors and also allow for certain arguments to take over the cli session.
I've looking more into my options here: https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options
If anyone else has experience with this I'd love some recommendations.
from cz-cli.
Thanks for the quick answer @jimthedev. It puzzled me as well, src\app.js
seemed to have provision for it, making it look like it was indeed supported:
// Pass through any additional arguments that would normally
// go to git.
var gitArgs = process.argv.slice(2, process.argv.length);
That left me wondering which Git arguments were indeed supported. A mystery. It would be a nice feature indeed, but with that being said, I can just do a git --amend
and edit manually. What I like about commitzen is that it provides the structure; as long as I have the type, scope, and message all laid out in the original message, I can write over each parts.
What I'm trying to do, however, is cleanup a small project. I want to rewrite the history to comply with conventional-changelog (the project has not been forked by others). The plan was to do a git rebase -i HEAD~30
, Git would rewind me back to the last commit in the list, and drop me on the command line with something like Stopped at f7f3f6d... You can amend the commit now, with git commit --amend. Once you’re satisfied with your changes, run git rebase --continue
. Something you are familiar with I'm sure. But instead of git commit --amend
I want to use git-cz --amend
of course, on all the 30 commits or so.
from cz-cli.
Gosh, this is why I love open source. So many interesting use cases. I am
out of town this weekend and am giving a talk next weekend so next week
will be a rough week as I prep but I'll try to look into how I could manage
the cli context better. It probably would have to be part of 2.0 which
would be over a month out. Thanks for outlining your use case.
On Thu, Sep 24, 2015 at 7:14 PM Sébastien Barré [email protected]
wrote:
Thanks for the quick answer @jimthedev https://github.com/jimthedev. It
puzzled me as well, src\app.js seemed to have provision for it, making it
look like it was indeed supported:// Pass through any additional arguments that would normally
// go to git.
var gitArgs = process.argv.slice(2, process.argv.length);That left me wondering which Git arguments were indeed supported. A
mystery. It would be a nice feature indeed, but with that being said, I can
just do a git --amend and edit manually. What I like about commitzen is
that it provides the structure; as long as I have the type, scope, and
message all laid out in the original message, I can write over each parts.What I'm trying to do, however, is cleanup a small project. I want to
rewrite the history to comply with conventional-changelog (the project has
not been forked by others). The plan was to do a git rebase -i HEAD~30,
Git would rewind me back to the last commit in the list, and drop me on the
command line with something like Stopped at f7f3f6d... You can amend the
commit now, with git commit --amend. Once you’re satisfied with your
changes, run git rebase --continue. Something you are familiar with I'm
sure. But instead of git commit --amend I want to use git-cz --amend of
course, on all the 30 commits or so.—
Reply to this email directly or view it on GitHub
#12 (comment).
from cz-cli.
Got it. Thanks for being open to the idea.
from cz-cli.
Commitizen is designed to pass any git parameters through to git. This is why git-cz -a
works. The problem is that since --amend opens an editor, we're no longer just simply dealing with cli parameters, but have to think about how we create or wrap processes.
from cz-cli.
Thanks @jimthedev ; so this might sound like a crazy idea, but what about intercepting --amend
and removing it from the parameters, then use git to query the last commit message, parse it, and pre-populate each of the questions git-cz
asks (i.e. the scope, message, description, etc. would be pre-entered, for the user to amend/modify). Now that would be magical :)
from cz-cli.
@sebastienbarre Ooo. I love that idea. The question is, what to do when parsing fails. Care to venture a PR :D
from cz-cli.
@sebastienbarre I was thinking about this a bit more. Specifically I was thinking about your idea of greping the git log. Turns out the tough part would not be getting the previous commit, but rather parsing it into fields. We could defer that functionality to the adapters.
In commitizen's current architecture, the adapters do exactly two things:
- capture user input
- output a string back to commitizen-cli
This would need to change if we implemented your feature. Specifically adapters would need to implement a method, say "amend" that re-runs their user input grabbing with certain fields pre-populated. In the current version, the cli doesn't care how adapters get input, as long as they return a template string. In this new scenario, we'd leave it up to the adapters to do more work in order to provide this functionality. I'm going to tentatively add this to 2.1.0 but it might get move around a bit depending on new bugs introduced in 2.0.
from cz-cli.
I agree with you, I think the adapters would have to do some work here.
Funny enough, I was thinking about this issue again this weekend, and decided it wasn't worth the effort rewriting the whole commit history.
What has bitten me a lot as of late though, is going through the whole set of questions, only to end up having to repeat the process again because I forgot to stage files. My muscle memory has always been git -a -m ...
, and now that I'm trying to use git-cz
, I often forget to issue git -A
beforehand. This means I have to stage files, re-run git-cz
, and copy/paste the answers from my previous try.
So here is what I think could be useful. And this should probably be handled by the adapters.
When git-cz
is invoked:
- open a temporary file (say, JSON),
- each time the user answers a question (be it type, scope, subject, body, etc), append it to the temporary file,
- if the commit succeeds, delete that temporary file.
The next time git-cz
is invoked:
- check if there is a temporary file,
- each time the user is prompted a question (be it type, scope, subject, body, etc), pre-populate the answer from the temporary file,
- if the commit succeeds, delete that temporary file.
This would address two things:
- if I forget to stage my files, the commit will fail, but I can just
git -A
, thengit-cz
again, and not have to enter all my answers again (I can press [Enter] a few times to accept all my previous choices). - if I quit /
Control+C
before the last answer because I realize I forgot to do something (say, bump a version, fix some code), I can still re-rungit-cz
and find my previous answers.
Just an idea.
from cz-cli.
Totally. In fact, there is an issue about what you mentioned here.
Obviously in Kent's proposed solution we would just not run the prompter and return an error immediately if there are no files staged. It is a simpler solution but should be pretty easy to implement vs the tmp file solution. Thoughts?
from cz-cli.
Oh yes, duh, I should have looked at the other issues, sorry.
from cz-cli.
No worries. :D
Ok, so, I am thinking I'll keep this open for now and we can re-evaluate once 2.0 drops.
from cz-cli.
Related Issues (20)
- NPM warning breaks `cz` prompts when using `scripts` entry
- commitizen produces empty commit message after answering prompts HOT 3
- Showing timing (progress) during commit cli
- Text alignment issues in smaller terminal windows on Mac HOT 2
- bug: issue with LRU cache, cannot execute `git-cz`
- [Config loader] check if config key is in package.json before accepting it as a config file HOT 1
- Weird behaviour when using cz cli (global) outside a git repo
- pathspec 'git' did not match any file(s) known to git HOT 2
- Feature request: Submit on the command line: Is there a way to return to the previous field? HOT 1
- Feature request: Whether to support multiple types of commits in one submission HOT 1
- commit npm script actually works
- husky hook does not work HOT 2
- Nestor David Sánchez
- Behaves the same as git commit HOT 1
- Provide a way to prompt to amend commit message only
- cz commit error
- Question: Is it possible to write an adapter in ES6?
- Cannot create release version after creating a pre-release version
- PNPM support is broken
- PNPM support is broken HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cz-cli.