mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +00:00
cli: branch: reject empty branch name consistently by "set"
Though "branch set" can't create new branch, this should provide a better error message.
This commit is contained in:
parent
d4e64c46b4
commit
5988a00ae4
3 changed files with 10 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
use clap::builder::NonEmptyStringValueParser;
|
||||||
use jj_lib::object_id::ObjectId as _;
|
use jj_lib::object_id::ObjectId as _;
|
||||||
use jj_lib::op_store::RefTarget;
|
use jj_lib::op_store::RefTarget;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ pub struct BranchSetArgs {
|
||||||
allow_backwards: bool,
|
allow_backwards: bool,
|
||||||
|
|
||||||
/// The branches to update
|
/// The branches to update
|
||||||
#[arg(required = true)]
|
#[arg(required = true, value_parser = NonEmptyStringValueParser::new())]
|
||||||
names: Vec<String>,
|
names: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,13 @@ fn test_branch_empty_name() {
|
||||||
|
|
||||||
For more information, try '--help'.
|
For more information, try '--help'.
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "set", ""]);
|
||||||
|
insta::assert_snapshot!(stderr, @r###"
|
||||||
|
error: a value is required for '<NAMES>...' but none was supplied
|
||||||
|
|
||||||
|
For more information, try '--help'.
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue