mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-07 21:27:06 +00:00
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
|
that describes them better, and they also behave similar to Mercurial's
|
||||||
bookmarks.
|
bookmarks.
|
||||||
|
|
||||||
|
* The `git.push-branch-prefix` config has been deprecated in favor of
|
||||||
|
`git.push-bookmark-prefix`.
|
||||||
|
|
||||||
### New features
|
### New features
|
||||||
|
|
||||||
* The new config option `snapshot.auto-track` lets you automatically track only
|
* 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();
|
let mut seen_bookmarks: HashSet<&str> = HashSet::new();
|
||||||
|
|
||||||
// Process --change bookmarks first because matching bookmarks can be moved.
|
// Process --change bookmarks first because matching bookmarks can be moved.
|
||||||
let change_bookmark_names = update_change_bookmarks(
|
// TODO: Drop support support for git.push-branch-prefix in 0.28.0+
|
||||||
ui,
|
let bookmark_prefix = if let Some(prefix) = command.settings().push_branch_prefix() {
|
||||||
&mut tx,
|
writeln!(
|
||||||
&args.change,
|
ui.warning_default(),
|
||||||
&command.settings().push_bookmark_prefix(),
|
"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 change_bookmarks = change_bookmark_names.iter().map(|bookmark_name| {
|
||||||
let targets = LocalAndRemoteRef {
|
let targets = LocalAndRemoteRef {
|
||||||
local_target: tx.repo().view().get_local_bookmark(bookmark_name),
|
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:
|
Bookmark changes to push to origin:
|
||||||
Add bookmark test-yostqsxwqrlt to 38cb417ce3a6
|
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]
|
#[test]
|
||||||
|
|
|
@ -196,6 +196,10 @@ impl UserSettings {
|
||||||
.unwrap_or_else(|_| "push-".to_string())
|
.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 {
|
pub fn default_description(&self) -> String {
|
||||||
self.config()
|
self.config()
|
||||||
.get_string("ui.default-description")
|
.get_string("ui.default-description")
|
||||||
|
|
Loading…
Reference in a new issue