mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-19 19:08:08 +00:00
cli: add --allow-empty-description flag to push
This commit adds an optional flag to be able to push commits with an empty description to a remote git repo. While the default behavior is ideal we might need to interact with a repo that has an empty commit description in it. I ran into this issue a few weeks ago pushing commits from an open source repo to an empty repo and had to go back to using git for that push as I would not want to rewrite the history which was many many years long just for that. This flag allows users an escape hatch for pushing empty descriptions for commits and they're sure that they want that behavior. This commit adds the flag to the `git push` command and updates the docs for the command. It also updates the original test to make sure that the flag works as intended to reject the commit when not set and to allow the commit when the flag is set. Closes #2633
This commit is contained in:
parent
a3c6a9b1b7
commit
3bc361a8b9
4 changed files with 21 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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>,
|
||||
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue