-
Notifications
You must be signed in to change notification settings - Fork 745
cli: add --stdin
and --edit
flags to jj commit
#7714
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Signed the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following commits do not follow our format for subject lines:
- c9d9117: Merge branch 'main' into commit-stdin-flag
Commits should have a subject line following the format <topic>: <description>
. Please review the commit guidelines for more information.
c9d9117
to
e23d47a
Compare
All commits are now correctly formatted. Thank you for your contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
let output = work_dir | ||
.run_jj_with(|cmd| cmd.args(["commit", "--stdin"]).write_stdin("Multi-line\n\ncommit message")) | ||
.success(); | ||
insta::assert_snapshot!(output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use inline version: insta::assert_snapshot!(output, @"");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you forgot to upload the latest change?
Add `--stdin` flag to read commit messages from stdin, matching the existing pattern in `jj describe`. This solves the problem of passing multi-line commit messages from scripts and the command line without shell escaping issues. Add `--edit` flag to allow opening an editor after providing a message via `--stdin` or `-m`, enabling users to refine messages in two stages. Implementation: - Added proper conflicts: `--stdin` cannot be used with `-m`, `--interactive`, or `--tool` - Restructured description handling to check stdin first, then -m flags, then fall back to editor - Introduced `use_editor` variable to control editor invocation - Trailers are properly handled in all code paths This brings `jj commit` to feature parity with `jj describe` for message input methods. Updates: - Added CHANGELOG entry - Added comprehensive tests for stdin functionality - All existing tests pass
e23d47a
to
292a096
Compare
Comments should be resolved! |
insta::assert_snapshot!( | ||
format!("-----\n{editor0}-----\n"), @r#" | ||
----- | ||
insta::assert_snapshot!(editor0, @r#" | ||
Reviewed-by: [email protected] | ||
Reviewed-by: [email protected] | ||
JJ: Change ID: zsuskuln | ||
JJ: | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
----- | ||
"#); | ||
JJ: Change ID: zsuskuln | ||
JJ: | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"#); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this change. I think the intent here is to ensure that the editor content is terminated by \n
. insta::assert_snapshot!()
isn't strict about leading/trailing newlines.
let output = work_dir | ||
.run_jj_with(|cmd| cmd.args(["commit", "--stdin"]).write_stdin("Multi-line\n\ncommit message")) | ||
.success(); | ||
insta::assert_snapshot!(output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you forgot to upload the latest change?
Add
--stdin
flag to read commit messages from stdin, matching the existing pattern injj describe
. This solves the problem of passing multi-line commit messages from scripts and the command line without shell escaping issues.Add
--edit
flag to allow opening an editor after providing a message via--stdin
or-m
, enabling users to refine messages in two stages.Implementation:
--stdin
cannot be used with-m
,--interactive
, or--tool
use_editor
variable to control editor invocationThis brings
jj commit
to feature parity withjj describe
for message input methods.Checklist