diff --git a/CHANGELOG.md b/CHANGELOG.md index bfd9ce82a57..6130c853856 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Upgraded `scm-record` from v0.2.0 to v0.3.0. See release notes at https://github.com/arxanas/scm-record/releases/tag/v0.3.0 +* `jj git push` now can push commits with empty descriptions with the + `--allow-empty-description` flag + ### Fixed bugs * Previously, `jj git push` only made sure that the branch is in the expected diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 42107fd0b8e..709c1a69f56 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -231,6 +231,9 @@ pub struct GitPushArgs { /// correspond to missing local branches. #[arg(long)] deleted: bool, + /// Allow pushing commits with empty descriptions + #[arg(long)] + allow_empty_description: bool, /// Push branches pointing to these commits (can be repeated) #[arg(long, short)] revisions: Vec, @@ -954,7 +957,7 @@ fn cmd_git_push( { let commit = commit?; let mut reasons = vec![]; - if commit.description().is_empty() { + if commit.description().is_empty() && !args.allow_empty_description { reasons.push("it has no description"); } if commit.author().name.is_empty() diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index afd5d40a355..9d59bc9d872 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -936,6 +936,10 @@ Before the command actually moves, creates, or deletes a remote branch, it makes Possible values: `true`, `false` +* `--allow-empty-description` — Allow pushing commits with empty descriptions + + Possible values: `true`, `false` + * `-r`, `--revisions ` — Push branches pointing to these commits (can be repeated) * `-c`, `--change ` — Push this commit by creating a branch based on its change ID (can be repeated) * `--dry-run` — Only display what will change on the remote diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index 1878df27742..9e3b01ce25b 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -823,6 +823,16 @@ fn test_git_push_no_description() { insta::assert_snapshot!(stderr, @r###" Error: Won't push commit 5b36783cd11c since it has no description "###); + test_env.jj_cmd_ok( + &workspace_root, + &[ + "git", + "push", + "--branch", + "my-branch", + "--allow-empty-description", + ], + ); } #[test]