forked from mirrors/jj
git: restore support for git.push-branch-prefix
config but deprecate it
This commit is contained in:
parent
136dcac1e1
commit
63e616c801
4 changed files with 39 additions and 6 deletions
|
@ -29,6 +29,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|||
that describes them better, and they also behave similar to Mercurial's
|
||||
bookmarks.
|
||||
|
||||
* The `git.push-branch-prefix` config has been deprecated in favor of
|
||||
`git.push-bookmark-prefix`.
|
||||
|
||||
### New features
|
||||
|
||||
* The new config option `snapshot.auto-track` lets you automatically track only
|
||||
|
|
|
@ -193,12 +193,19 @@ pub fn cmd_git_push(
|
|||
let mut seen_bookmarks: HashSet<&str> = HashSet::new();
|
||||
|
||||
// Process --change bookmarks first because matching bookmarks can be moved.
|
||||
let change_bookmark_names = update_change_bookmarks(
|
||||
ui,
|
||||
&mut tx,
|
||||
&args.change,
|
||||
&command.settings().push_bookmark_prefix(),
|
||||
)?;
|
||||
// TODO: Drop support support for git.push-branch-prefix in 0.28.0+
|
||||
let bookmark_prefix = if let Some(prefix) = command.settings().push_branch_prefix() {
|
||||
writeln!(
|
||||
ui.warning_default(),
|
||||
"Config git.push-branch-prefix is deprecated. Please switch to \
|
||||
git.push-bookmark-prefix",
|
||||
)?;
|
||||
prefix
|
||||
} else {
|
||||
command.settings().push_bookmark_prefix()
|
||||
};
|
||||
let change_bookmark_names =
|
||||
update_change_bookmarks(ui, &mut tx, &args.change, &bookmark_prefix)?;
|
||||
let change_bookmarks = change_bookmark_names.iter().map(|bookmark_name| {
|
||||
let targets = LocalAndRemoteRef {
|
||||
local_target: tx.repo().view().get_local_bookmark(bookmark_name),
|
||||
|
|
|
@ -679,6 +679,25 @@ fn test_git_push_changes() {
|
|||
Bookmark changes to push to origin:
|
||||
Add bookmark test-yostqsxwqrlt to 38cb417ce3a6
|
||||
"###);
|
||||
|
||||
// Test deprecation warning for `git.push-branch-prefix`
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(
|
||||
&workspace_root,
|
||||
&[
|
||||
"git",
|
||||
"push",
|
||||
"--config-toml",
|
||||
r"git.push-branch-prefix='branch-'",
|
||||
"--change=@",
|
||||
],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Warning: Config git.push-branch-prefix is deprecated. Please switch to git.push-bookmark-prefix
|
||||
Creating bookmark branch-yostqsxwqrlt for revision yostqsxwqrlt
|
||||
Bookmark changes to push to origin:
|
||||
Add bookmark branch-yostqsxwqrlt to 38cb417ce3a6
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -196,6 +196,10 @@ impl UserSettings {
|
|||
.unwrap_or_else(|_| "push-".to_string())
|
||||
}
|
||||
|
||||
pub fn push_branch_prefix(&self) -> Option<String> {
|
||||
self.config.get_string("git.push-branch-prefix").ok()
|
||||
}
|
||||
|
||||
pub fn default_description(&self) -> String {
|
||||
self.config()
|
||||
.get_string("ui.default-description")
|
||||
|
|
Loading…
Reference in a new issue