Skip to content
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

cli: add --allow-empty-description flag to push #3653

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `jj new`'s `--insert-before` and `--insert-after` options can now be used
simultaneously.

* `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
Expand Down
5 changes: 4 additions & 1 deletion cli/src/commands/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RevisionArg>,
Expand Down Expand Up @@ -959,7 +962,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()
Expand Down
4 changes: 4 additions & 0 deletions cli/tests/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,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 <REVISIONS>` — Push branches pointing to these commits (can be repeated)
* `-c`, `--change <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
Expand Down
10 changes: 10 additions & 0 deletions cli/tests/test_git_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down