diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 9f22ca7c4b..19ef027bf6 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -220,6 +220,9 @@ pub struct GitPushArgs { /// correspond to missing local branches. #[arg(long)] deleted: bool, + /// Push branches that contain empty descriptions + #[arg(long)] + allow_empty_description: bool, /// Push branches pointing to these commits (can be repeated) #[arg(long, short)] revisions: Vec, @@ -930,7 +933,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 ba895fff64..38e4a9d991 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -1,6 +1,5 @@ --- source: cli/tests/test_generate_md_cli_help.rs -description: "AUTO-GENERATED FILE, DO NOT EDIT. This cli reference is generated as an `insta` snapshot. MkDocs follows they symlink from docs/cli-reference.md to the snap. Unfortunately, `insta` unavoidably creates this header. Luckily, MkDocs ignores the header since it has the same format as Markdown headers. TODO: MkDocs may fail on Windows if symlinks are not enabled in the OS settings" --- @@ -931,6 +930,10 @@ By default, pushes any branches pointing to `remote_branches(remote=)..@ Possible values: `true`, `false` +* `--allow-empty-description` — Push branches that contain 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 6d8bf2b215..59b0088cc7 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -644,6 +644,23 @@ fn test_git_push_no_description() { "###); } +#[test] +fn test_git_allow_push_no_description() { + let (test_env, workspace_root) = set_up(); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "my-branch"]); + test_env.jj_cmd_ok(&workspace_root, &["describe", "-m="]); + test_env.jj_cmd_ok( + &workspace_root, + &[ + "git", + "push", + "--branch", + "my-branch", + "--allow-empty-description", + ], + ); +} + #[test] fn test_git_push_missing_author() { let (test_env, workspace_root) = set_up();