2023-02-03 07:45:54 +00:00
// Copyright 2023 The Jujutsu Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use std ::path ::Path ;
use crate ::common ::TestEnvironment ;
2024-08-21 19:59:15 +00:00
/// Creates a remote Git repo containing a bookmark with the same name
2023-08-29 04:45:56 +00:00
fn init_git_remote ( test_env : & TestEnvironment , remote : & str ) {
2023-02-20 03:11:02 +00:00
let git_repo_path = test_env . env_root ( ) . join ( remote ) ;
let git_repo = git2 ::Repository ::init ( git_repo_path ) . unwrap ( ) ;
let signature =
git2 ::Signature ::new ( " Some One " , " some.one@example.com " , & git2 ::Time ::new ( 0 , 0 ) ) . unwrap ( ) ;
let mut tree_builder = git_repo . treebuilder ( None ) . unwrap ( ) ;
2023-02-24 17:24:48 +00:00
let file_oid = git_repo . blob ( remote . as_bytes ( ) ) . unwrap ( ) ;
2023-02-20 03:11:02 +00:00
tree_builder
. insert ( " file " , file_oid , git2 ::FileMode ::Blob . into ( ) )
. unwrap ( ) ;
let tree_oid = tree_builder . write ( ) . unwrap ( ) ;
let tree = git_repo . find_tree ( tree_oid ) . unwrap ( ) ;
git_repo
. commit (
Some ( & format! ( " refs/heads/ {remote} " ) ) ,
& signature ,
& signature ,
" message " ,
& tree ,
& [ ] ,
)
. unwrap ( ) ;
2023-08-29 04:45:56 +00:00
}
2024-08-21 19:59:15 +00:00
/// Add a remote containing a bookmark with the same name
2023-08-29 04:45:56 +00:00
fn add_git_remote ( test_env : & TestEnvironment , repo_path : & Path , remote : & str ) {
init_git_remote ( test_env , remote ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-02-20 03:11:02 +00:00
repo_path ,
& [ " git " , " remote " , " add " , remote , & format! ( " ../ {remote} " ) ] ,
) ;
}
2024-08-21 19:59:15 +00:00
fn get_bookmark_output ( test_env : & TestEnvironment , repo_path : & Path ) -> String {
// --quiet to suppress deleted bookmarks hint
test_env . jj_cmd_success ( repo_path , & [ " bookmark " , " list " , " --all-remotes " , " --quiet " ] )
2023-02-20 03:11:02 +00:00
}
2023-01-12 22:53:26 +00:00
fn create_commit ( test_env : & TestEnvironment , repo_path : & Path , name : & str , parents : & [ & str ] ) {
let descr = format! ( " descr_for_ {name} " ) ;
if parents . is_empty ( ) {
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( repo_path , & [ " new " , " root() " , " -m " , & descr ] ) ;
2023-01-12 22:53:26 +00:00
} else {
let mut args = vec! [ " new " , " -m " , & descr ] ;
args . extend ( parents ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( repo_path , & args ) ;
2023-01-12 22:53:26 +00:00
}
std ::fs ::write ( repo_path . join ( name ) , format! ( " {name} \n " ) ) . unwrap ( ) ;
2024-08-21 19:59:15 +00:00
test_env . jj_cmd_ok ( repo_path , & [ " bookmark " , " create " , name ] ) ;
2023-01-12 22:53:26 +00:00
}
fn get_log_output ( test_env : & TestEnvironment , workspace_root : & Path ) -> String {
2024-08-21 19:59:15 +00:00
let template = r # "commit_id.short() ++ " " ++ description.first_line() ++ " " ++ bookmarks"# ;
2023-02-28 10:43:14 +00:00
test_env . jj_cmd_success ( workspace_root , & [ " log " , " -T " , template , " -r " , " all() " ] )
2023-01-12 22:53:26 +00:00
}
2023-12-16 10:01:44 +00:00
#[ test ]
fn test_git_fetch_with_default_config ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-12-16 10:01:44 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " origin " ) ;
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-12-16 10:01:44 +00:00
origin @ origin : oputwtnw ffecd2d6 message
" ###);
}
2023-02-03 07:45:54 +00:00
#[ test ]
fn test_git_fetch_default_remote ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-03 07:45:54 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " origin " ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
origin : oputwtnw ffecd2d6 message
2023-10-18 06:12:17 +00:00
@ origin : oputwtnw ffecd2d6 message
2023-02-03 07:45:54 +00:00
" ###);
}
#[ test ]
fn test_git_fetch_single_remote ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-03 07:45:54 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
2024-03-24 07:00:46 +00:00
let ( _stdout , stderr ) = test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-03-24 06:47:47 +00:00
Hint : Fetching from the only existing remote : rem1
2024-09-11 16:11:50 +00:00
bookmark : rem1 @ rem1 [ new ] tracked
2024-03-24 07:00:46 +00:00
" ###);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
rem1 : qxosxrvv 6 a211027 message
2023-10-18 06:12:17 +00:00
@ rem1 : qxosxrvv 6 a211027 message
2023-04-04 13:34:12 +00:00
" ###);
}
2023-08-22 10:21:02 +00:00
#[ test ]
fn test_git_fetch_single_remote_all_remotes_flag ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-08-22 10:21:02 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
test_env
. jj_cmd ( & repo_path , & [ " git " , " fetch " , " --all-remotes " ] )
. assert ( )
. success ( ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-08-22 10:21:02 +00:00
rem1 : qxosxrvv 6 a211027 message
2023-10-18 06:12:17 +00:00
@ rem1 : qxosxrvv 6 a211027 message
2023-08-22 10:21:02 +00:00
" ###);
}
2023-04-04 13:34:12 +00:00
#[ test ]
fn test_git_fetch_single_remote_from_arg ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-04-04 13:34:12 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --remote " , " rem1 " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
rem1 : qxosxrvv 6 a211027 message
2023-10-18 06:12:17 +00:00
@ rem1 : qxosxrvv 6 a211027 message
2023-02-03 07:45:54 +00:00
" ###);
}
#[ test ]
fn test_git_fetch_single_remote_from_config ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-03 07:45:54 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
test_env . add_config ( r # "git.fetch = "rem1""# ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
rem1 : qxosxrvv 6 a211027 message
2023-10-18 06:12:17 +00:00
@ rem1 : qxosxrvv 6 a211027 message
2023-02-03 07:45:54 +00:00
" ###);
}
2023-02-02 18:31:11 +00:00
#[ test ]
fn test_git_fetch_multiple_remotes ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-02 18:31:11 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
add_git_remote ( & test_env , & repo_path , " rem2 " ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-02-02 18:31:11 +00:00
& repo_path ,
& [ " git " , " fetch " , " --remote " , " rem1 " , " --remote " , " rem2 " ] ,
) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
rem1 : qxosxrvv 6 a211027 message
2023-10-18 06:12:17 +00:00
@ rem1 : qxosxrvv 6 a211027 message
2023-07-11 01:46:38 +00:00
rem2 : yszkquru 2497 a8a0 message
2023-10-18 06:12:17 +00:00
@ rem2 : yszkquru 2497 a8a0 message
2023-02-02 18:31:11 +00:00
" ###);
}
2023-08-22 10:21:02 +00:00
#[ test ]
fn test_git_fetch_all_remotes ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-08-22 10:21:02 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
add_git_remote ( & test_env , & repo_path , " rem2 " ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --all-remotes " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-08-22 10:21:02 +00:00
rem1 : qxosxrvv 6 a211027 message
2023-10-18 06:12:17 +00:00
@ rem1 : qxosxrvv 6 a211027 message
2023-08-22 10:21:02 +00:00
rem2 : yszkquru 2497 a8a0 message
2023-10-18 06:12:17 +00:00
@ rem2 : yszkquru 2497 a8a0 message
2023-08-22 10:21:02 +00:00
" ###);
}
2023-02-02 18:31:11 +00:00
#[ test ]
fn test_git_fetch_multiple_remotes_from_config ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-02 18:31:11 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
add_git_remote ( & test_env , & repo_path , " rem2 " ) ;
test_env . add_config ( r # "git.fetch = ["rem1", "rem2"]"# ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
rem1 : qxosxrvv 6 a211027 message
2023-10-18 06:12:17 +00:00
@ rem1 : qxosxrvv 6 a211027 message
2023-07-11 01:46:38 +00:00
rem2 : yszkquru 2497 a8a0 message
2023-10-18 06:12:17 +00:00
@ rem2 : yszkquru 2497 a8a0 message
2023-02-02 18:31:11 +00:00
" ###);
}
2023-02-03 07:45:54 +00:00
#[ test ]
fn test_git_fetch_nonexistent_remote ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-03 07:45:54 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
2023-02-02 18:31:11 +00:00
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
2023-02-03 07:45:54 +00:00
2023-02-02 18:31:11 +00:00
let stderr = & test_env . jj_cmd_failure (
& repo_path ,
& [ " git " , " fetch " , " --remote " , " rem1 " , " --remote " , " rem2 " ] ,
) ;
2023-02-03 07:45:54 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : rem1 @ rem1 [ new ] untracked
2023-02-02 18:31:11 +00:00
Error : No git remote named ' rem2 '
2023-02-03 07:45:54 +00:00
" ###);
// No remote should have been fetched as part of the failing transaction
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ " " ) ;
2023-02-03 07:45:54 +00:00
}
#[ test ]
fn test_git_fetch_nonexistent_remote_from_config ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-03 07:45:54 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
2023-02-02 18:31:11 +00:00
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
test_env . add_config ( r # "git.fetch = ["rem1", "rem2"]"# ) ;
2023-02-03 07:45:54 +00:00
let stderr = & test_env . jj_cmd_failure ( & repo_path , & [ " git " , " fetch " ] ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : rem1 @ rem1 [ new ] untracked
2023-02-02 18:31:11 +00:00
Error : No git remote named ' rem2 '
2023-02-03 07:45:54 +00:00
" ###);
// No remote should have been fetched as part of the failing transaction
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ " " ) ;
2023-02-03 07:45:54 +00:00
}
2023-08-29 04:45:56 +00:00
#[ test ]
fn test_git_fetch_from_remote_named_git ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2023-08-29 04:45:56 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
init_git_remote ( & test_env , " git " ) ;
let git_repo = git2 ::Repository ::init ( & repo_path ) . unwrap ( ) ;
git_repo . remote ( " git " , " ../git " ) . unwrap ( ) ;
// Existing remote named 'git' shouldn't block the repo initialization.
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " init " , " --git-repo=. " ] ) ;
2023-08-29 04:45:56 +00:00
// Try fetching from the remote named 'git'.
let stderr = & test_env . jj_cmd_failure ( & repo_path , & [ " git " , " fetch " , " --remote=git " ] ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-03-16 02:57:33 +00:00
Error : Failed to import refs from underlying Git repo
Caused by : Git remote named ' git ' is reserved for local Git repository
2023-08-29 04:45:56 +00:00
Hint : Run ` jj git remote rename ` to give different name .
" ###);
// Implicit import shouldn't fail because of the remote ref.
2024-08-21 19:59:15 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & repo_path , & [ " bookmark " , " list " , " --all-remotes " ] ) ;
2023-08-29 04:45:56 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2023-10-10 11:59:18 +00:00
insta ::assert_snapshot! ( stderr , @ " " ) ;
2023-08-29 04:45:56 +00:00
// Explicit import is an error.
// (This could be warning if we add mechanism to report ignored refs.)
insta ::assert_snapshot! ( test_env . jj_cmd_failure ( & repo_path , & [ " git " , " import " ] ) , @ r ###"
2024-03-16 02:57:33 +00:00
Error : Failed to import refs from underlying Git repo
Caused by : Git remote named ' git ' is reserved for local Git repository
2023-08-29 04:45:56 +00:00
Hint : Run ` jj git remote rename ` to give different name .
" ###);
// The remote can be renamed, and the ref can be imported.
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " remote " , " rename " , " git " , " bar " ] ) ;
2024-08-21 19:59:15 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & repo_path , & [ " bookmark " , " list " , " --all-remotes " ] ) ;
2023-08-29 04:45:56 +00:00
insta ::assert_snapshot! ( stdout , @ r ###"
git : mrylzrtu 76 fc7466 message
2023-10-18 06:12:17 +00:00
@ bar : mrylzrtu 76 fc7466 message
@ git : mrylzrtu 76 fc7466 message
2023-08-29 04:45:56 +00:00
" ###);
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
Done importing changes from the underlying Git repo .
" ###);
2023-08-29 04:45:56 +00:00
}
2023-02-11 10:11:33 +00:00
#[ test ]
fn test_git_fetch_prune_before_updating_tips ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-11 10:11:33 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " origin " ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
origin : oputwtnw ffecd2d6 message
2023-10-18 06:12:17 +00:00
@ origin : oputwtnw ffecd2d6 message
2023-02-11 10:11:33 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Remove origin bookmark in git repo and create origin/subname
2023-02-11 10:11:33 +00:00
let git_repo = git2 ::Repository ::open ( test_env . env_root ( ) . join ( " origin " ) ) . unwrap ( ) ;
git_repo
. find_branch ( " origin " , git2 ::BranchType ::Local )
. unwrap ( )
. rename ( " origin/subname " , false )
. unwrap ( ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
origin / subname : oputwtnw ffecd2d6 message
2023-10-18 06:12:17 +00:00
@ origin : oputwtnw ffecd2d6 message
2023-02-12 00:43:38 +00:00
" ###);
2023-02-11 10:11:33 +00:00
}
2023-01-12 22:53:26 +00:00
#[ test ]
2024-08-21 19:59:15 +00:00
fn test_git_fetch_conflicting_bookmarks ( ) {
2023-01-12 22:53:26 +00:00
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-01-12 22:53:26 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
2024-08-21 19:59:15 +00:00
// Create a rem1 bookmark locally
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " new " , " root() " ] ) ;
2024-08-21 19:59:15 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " bookmark " , " create " , " rem1 " ] ) ;
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
rem1 : kkmpptxz fcdbbd73 ( empty ) ( no description set )
2023-01-12 22:53:26 +00:00
" ###);
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-01-12 22:53:26 +00:00
& repo_path ,
2023-10-23 23:29:42 +00:00
& [ " git " , " fetch " , " --remote " , " rem1 " , " --branch " , " glob:* " ] ,
2023-01-12 22:53:26 +00:00
) ;
2024-08-21 19:59:15 +00:00
// This should result in a CONFLICTED bookmark
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-01-12 22:53:26 +00:00
rem1 ( conflicted ) :
2023-07-11 01:46:38 +00:00
+ kkmpptxz fcdbbd73 ( empty ) ( no description set )
+ qxosxrvv 6 a211027 message
@ rem1 ( behind by 1 commits ) : qxosxrvv 6 a211027 message
2023-01-12 22:53:26 +00:00
" ###);
}
#[ test ]
2024-08-21 19:59:15 +00:00
fn test_git_fetch_conflicting_bookmarks_colocated ( ) {
2023-01-12 22:53:26 +00:00
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2023-01-12 22:53:26 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
let _git_repo = git2 ::Repository ::init ( & repo_path ) . unwrap ( ) ;
2024-08-21 19:59:15 +00:00
// create_colocated_repo_and_bookmarks_from_trunk1(&test_env, &repo_path);
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " init " , " --git-repo " , " . " ] ) ;
2023-01-12 22:53:26 +00:00
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ " " ) ;
2023-01-12 22:53:26 +00:00
2024-08-21 19:59:15 +00:00
// Create a rem1 bookmark locally
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " new " , " root() " ] ) ;
2024-08-21 19:59:15 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " bookmark " , " create " , " rem1 " ] ) ;
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
rem1 : zsuskuln f652c321 ( empty ) ( no description set )
2023-10-18 06:12:17 +00:00
@ git : zsuskuln f652c321 ( empty ) ( no description set )
2023-01-12 22:53:26 +00:00
" ###);
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-01-12 22:53:26 +00:00
& repo_path ,
& [ " git " , " fetch " , " --remote " , " rem1 " , " --branch " , " rem1 " ] ,
) ;
2024-08-21 19:59:15 +00:00
// This should result in a CONFLICTED bookmark
2024-12-17 19:01:42 +00:00
// See https://github.com/jj-vcs/jj/pull/1146#discussion_r1112372340 for the bug this tests for.
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-01-12 22:53:26 +00:00
rem1 ( conflicted ) :
2023-07-11 01:46:38 +00:00
+ zsuskuln f652c321 ( empty ) ( no description set )
+ qxosxrvv 6 a211027 message
@ git ( behind by 1 commits ) : zsuskuln f652c321 ( empty ) ( no description set )
@ rem1 ( behind by 1 commits ) : qxosxrvv 6 a211027 message
2023-01-12 22:53:26 +00:00
" ###);
}
2024-08-21 19:59:15 +00:00
// Helper functions to test obtaining multiple bookmarks at once and changed
// bookmarks
fn create_colocated_repo_and_bookmarks_from_trunk1 (
2023-01-12 22:53:26 +00:00
test_env : & TestEnvironment ,
repo_path : & Path ,
) -> String {
// Create a colocated repo in `source` to populate it more easily
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( repo_path , & [ " git " , " init " , " --git-repo " , " . " ] ) ;
2023-01-12 22:53:26 +00:00
create_commit ( test_env , repo_path , " trunk1 " , & [ ] ) ;
create_commit ( test_env , repo_path , " a1 " , & [ " trunk1 " ] ) ;
create_commit ( test_env , repo_path , " a2 " , & [ " trunk1 " ] ) ;
create_commit ( test_env , repo_path , " b " , & [ " trunk1 " ] ) ;
format! (
" ===== Source git repo contents ===== \n {} " ,
get_log_output ( test_env , repo_path )
)
}
2024-08-21 19:59:15 +00:00
fn create_trunk2_and_rebase_bookmarks ( test_env : & TestEnvironment , repo_path : & Path ) -> String {
2023-01-12 22:53:26 +00:00
create_commit ( test_env , repo_path , " trunk2 " , & [ " trunk1 " ] ) ;
for br in [ " a1 " , " a2 " , " b " ] {
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( repo_path , & [ " rebase " , " -b " , br , " -d " , " trunk2 " ] ) ;
2023-01-12 22:53:26 +00:00
}
format! (
" ===== Source git repo contents ===== \n {} " ,
get_log_output ( test_env , repo_path )
)
}
#[ test ]
fn test_git_fetch_all ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).
This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.
Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.
For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-02 02:12:01 +00:00
test_env . add_config ( r # "revset-aliases."immutable_heads()" = "none()""# ) ;
2023-01-12 22:53:26 +00:00
let source_git_repo_path = test_env . env_root ( ) . join ( " source " ) ;
let _git_repo = git2 ::Repository ::init ( source_git_repo_path . clone ( ) ) . unwrap ( ) ;
// Clone an empty repo. The target repo is a normal `jj` repo, *not* colocated
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " clone " , " source " , " target " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-01-12 22:53:26 +00:00
Fetching into new repo in " $TEST_ENV/target "
Nothing changed .
" ###);
let target_jj_repo_path = test_env . env_root ( ) . join ( " target " ) ;
let source_log =
2024-08-21 19:59:15 +00:00
create_colocated_repo_and_bookmarks_from_trunk1 ( & test_env , & source_git_repo_path ) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
@ c7d4bdcbc215 descr_for_b b
2024-07-15 22:20:10 +00:00
│ ○ decaa3966c83 descr_for_a2 a2
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 359 a9a02457d descr_for_a1 a1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
// Nothing in our repo before the fetch
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r ###"
@ 230 dd059e1b0
2024-07-15 22:20:10 +00:00
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & target_jj_repo_path ) , @ " " ) ;
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " ] ) ;
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ new ] tracked
bookmark : a2 @ origin [ new ] tracked
bookmark : b @ origin [ new ] tracked
bookmark : trunk1 @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & target_jj_repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
a1 : nknoxmzm 359 a9a02 descr_for_a1
2023-10-18 06:12:17 +00:00
@ origin : nknoxmzm 359 a9a02 descr_for_a1
2023-07-11 01:46:38 +00:00
a2 : qkvnknrk decaa396 descr_for_a2
2023-10-18 06:12:17 +00:00
@ origin : qkvnknrk decaa396 descr_for_a2
2023-07-11 01:46:38 +00:00
b : vpupmnsl c7d4bdcb descr_for_b
2023-10-18 06:12:17 +00:00
@ origin : vpupmnsl c7d4bdcb descr_for_b
2023-07-11 01:46:38 +00:00
trunk1 : zowqyktl ff36dc55 descr_for_trunk1
2023-10-18 06:12:17 +00:00
@ origin : zowqyktl ff36dc55 descr_for_trunk1
2023-01-12 22:53:26 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1 trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-01-12 22:53:26 +00:00
// ==== Change both repos ====
// First, change the target repo:
2024-08-21 19:59:15 +00:00
let source_log = create_trunk2_and_rebase_bookmarks ( & test_env , & source_git_repo_path ) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
2024-07-15 22:20:10 +00:00
○ babc49226c14 descr_for_b b
│ ○ 91e46 b4b2653 descr_for_a2 a2
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 0424 f6dfc1ff descr_for_a1 a1
2023-01-12 22:53:26 +00:00
├ ─ ╯
@ 8 f1f14fbbf42 descr_for_trunk2 trunk2
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Change a bookmark in the source repo as well, so that it becomes conflicted.
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-01-12 22:53:26 +00:00
& target_jj_repo_path ,
& [ " describe " , " b " , " -m=new_descr_for_b_to_create_conflict " ] ,
) ;
// Our repo before and after fetch
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ 061 eddbb43ab new_descr_for_b_to_create_conflict b *
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1 trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & target_jj_repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
a1 : nknoxmzm 359 a9a02 descr_for_a1
2023-10-18 06:12:17 +00:00
@ origin : nknoxmzm 359 a9a02 descr_for_a1
2023-07-11 01:46:38 +00:00
a2 : qkvnknrk decaa396 descr_for_a2
2023-10-18 06:12:17 +00:00
@ origin : qkvnknrk decaa396 descr_for_a2
2023-07-11 01:46:38 +00:00
b : vpupmnsl 061 eddbb new_descr_for_b_to_create_conflict
2023-10-24 01:43:12 +00:00
@ origin ( ahead by 1 commits , behind by 1 commits ) : vpupmnsl hidden c7d4bdcb descr_for_b
2023-07-11 01:46:38 +00:00
trunk1 : zowqyktl ff36dc55 descr_for_trunk1
2023-10-18 06:12:17 +00:00
@ origin : zowqyktl ff36dc55 descr_for_trunk1
2023-01-12 22:53:26 +00:00
" ###);
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ updated ] tracked
bookmark : a2 @ origin [ updated ] tracked
bookmark : b @ origin [ updated ] tracked
bookmark : trunk2 @ origin [ new ] tracked
2023-10-03 02:50:13 +00:00
Abandoned 2 commits that are no longer reachable .
2023-09-30 05:04:44 +00:00
" ###);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & target_jj_repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
a1 : quxllqov 0424 f6df descr_for_a1
2023-10-18 06:12:17 +00:00
@ origin : quxllqov 0424 f6df descr_for_a1
2023-07-11 01:46:38 +00:00
a2 : osusxwst 91e46 b4b descr_for_a2
2023-10-18 06:12:17 +00:00
@ origin : osusxwst 91e46 b4b descr_for_a2
2023-01-12 22:53:26 +00:00
b ( conflicted ) :
2023-10-24 01:43:12 +00:00
- vpupmnsl hidden c7d4bdcb descr_for_b
2023-07-11 01:46:38 +00:00
+ vpupmnsl 061 eddbb new_descr_for_b_to_create_conflict
+ vktnwlsu babc4922 descr_for_b
@ origin ( behind by 1 commits ) : vktnwlsu babc4922 descr_for_b
trunk1 : zowqyktl ff36dc55 descr_for_trunk1
2023-10-18 06:12:17 +00:00
@ origin : zowqyktl ff36dc55 descr_for_trunk1
2023-07-11 01:46:38 +00:00
trunk2 : umznmzko 8 f1f14fb descr_for_trunk2
2023-10-18 06:12:17 +00:00
@ origin : umznmzko 8 f1f14fb descr_for_trunk2
2023-01-12 22:53:26 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ babc49226c14 descr_for_b b ? ? b @ origin
│ │ ○ 91e46 b4b2653 descr_for_a2 a2
│ ├ ─ ╯
│ │ ○ 0424 f6dfc1ff descr_for_a1 a1
│ ├ ─ ╯
│ ○ 8 f1f14fbbf42 descr_for_trunk2 trunk2
│ │ ○ 061 eddbb43ab new_descr_for_b_to_create_conflict b ? ?
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1 trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-01-12 22:53:26 +00:00
}
#[ test ]
2024-08-21 19:59:15 +00:00
fn test_git_fetch_some_of_many_bookmarks ( ) {
2023-01-12 22:53:26 +00:00
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).
This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.
Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.
For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-02 02:12:01 +00:00
test_env . add_config ( r # "revset-aliases."immutable_heads()" = "none()""# ) ;
2023-01-12 22:53:26 +00:00
let source_git_repo_path = test_env . env_root ( ) . join ( " source " ) ;
let _git_repo = git2 ::Repository ::init ( source_git_repo_path . clone ( ) ) . unwrap ( ) ;
// Clone an empty repo. The target repo is a normal `jj` repo, *not* colocated
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " clone " , " source " , " target " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-01-12 22:53:26 +00:00
Fetching into new repo in " $TEST_ENV/target "
Nothing changed .
" ###);
let target_jj_repo_path = test_env . env_root ( ) . join ( " target " ) ;
let source_log =
2024-08-21 19:59:15 +00:00
create_colocated_repo_and_bookmarks_from_trunk1 ( & test_env , & source_git_repo_path ) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
@ c7d4bdcbc215 descr_for_b b
2024-07-15 22:20:10 +00:00
│ ○ decaa3966c83 descr_for_a2 a2
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 359 a9a02457d descr_for_a1 a1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
// Test an error message
2023-10-23 23:29:42 +00:00
let stderr = test_env . jj_cmd_failure (
& target_jj_repo_path ,
& [ " git " , " fetch " , " --branch " , " glob:^:a* " ] ,
) ;
2024-11-20 05:19:43 +00:00
insta ::assert_snapshot! ( stderr , @ " Error: Invalid branch pattern provided. When fetching, branch names and globs may not contain the characters `:`, `^`, `?`, `[`, `]` " ) ;
2023-10-23 23:29:42 +00:00
let stderr = test_env . jj_cmd_failure ( & target_jj_repo_path , & [ " git " , " fetch " , " --branch " , " a* " ] ) ;
2024-11-20 05:19:43 +00:00
insta ::assert_snapshot! ( stderr , @ r "
Error : Branch names may not include ` * ` .
2023-10-23 23:29:42 +00:00
Hint : Prefix the pattern with ` glob :` to expand ` * ` as a glob
2024-11-20 05:19:43 +00:00
" );
2023-01-12 22:53:26 +00:00
// Nothing in our repo before the fetch
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r ###"
@ 230 dd059e1b0
2024-07-15 22:20:10 +00:00
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Fetch one bookmark...
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " , " --branch " , " b " ] ) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : b @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-01-12 22:53:26 +00:00
// ...check what the intermediate state looks like...
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & target_jj_repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
b : vpupmnsl c7d4bdcb descr_for_b
2023-10-18 06:12:17 +00:00
@ origin : vpupmnsl c7d4bdcb descr_for_b
2023-01-12 22:53:26 +00:00
" ###);
// ...then fetch two others with a glob.
2023-10-23 23:29:42 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok (
& target_jj_repo_path ,
& [ " git " , " fetch " , " --branch " , " glob:a* " ] ,
) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ new ] tracked
bookmark : a2 @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ decaa3966c83 descr_for_a2 a2
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ │ ○ c7d4bdcbc215 descr_for_b b
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2024-08-21 19:59:15 +00:00
// Fetching the same bookmark again
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " , " --branch " , " a1 " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-01-12 22:53:26 +00:00
Nothing changed .
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ decaa3966c83 descr_for_a2 a2
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ │ ○ c7d4bdcbc215 descr_for_b b
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-01-12 22:53:26 +00:00
// ==== Change both repos ====
// First, change the target repo:
2024-08-21 19:59:15 +00:00
let source_log = create_trunk2_and_rebase_bookmarks ( & test_env , & source_git_repo_path ) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
2024-07-15 22:20:10 +00:00
○ 01 d115196c39 descr_for_b b
│ ○ 31 c7d94b1f29 descr_for_a2 a2
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 6 df2d34cf0da descr_for_a1 a1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2023-10-23 23:29:42 +00:00
@ 2 bb3ebd2bba3 descr_for_trunk2 trunk2
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Change a bookmark in the source repo as well, so that it becomes conflicted.
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-01-12 22:53:26 +00:00
& target_jj_repo_path ,
& [ " describe " , " b " , " -m=new_descr_for_b_to_create_conflict " ] ,
) ;
2024-08-21 19:59:15 +00:00
// Our repo before and after fetch of two bookmarks
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ 6 ebd41dc4f13 new_descr_for_b_to_create_conflict b *
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok (
2023-01-12 22:53:26 +00:00
& target_jj_repo_path ,
& [ " git " , " fetch " , " --branch " , " b " , " --branch " , " a1 " ] ,
) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ updated ] tracked
bookmark : b @ origin [ updated ] tracked
2023-10-03 02:50:13 +00:00
Abandoned 1 commits that are no longer reachable .
2023-09-30 05:04:44 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ 01 d115196c39 descr_for_b b ? ? b @ origin
│ │ ○ 6 df2d34cf0da descr_for_a1 a1
│ ├ ─ ╯
│ ○ 2 bb3ebd2bba3 descr_for_trunk2
│ │ ○ 6 ebd41dc4f13 new_descr_for_b_to_create_conflict b ? ?
│ ├ ─ ╯
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-01-12 22:53:26 +00:00
2024-08-21 19:59:15 +00:00
// We left a2 where it was before, let's see how `jj bookmark list` sees this.
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & target_jj_repo_path ) , @ r ###"
2023-10-23 23:29:42 +00:00
a1 : ypowunwp 6 df2d34c descr_for_a1
@ origin : ypowunwp 6 df2d34c descr_for_a1
2023-07-11 01:46:38 +00:00
a2 : qkvnknrk decaa396 descr_for_a2
2023-10-18 06:12:17 +00:00
@ origin : qkvnknrk decaa396 descr_for_a2
2023-01-12 22:53:26 +00:00
b ( conflicted ) :
2023-10-24 01:43:12 +00:00
- vpupmnsl hidden c7d4bdcb descr_for_b
2023-10-23 23:29:42 +00:00
+ vpupmnsl 6 ebd41dc new_descr_for_b_to_create_conflict
+ nxrpswuq 01 d11519 descr_for_b
@ origin ( behind by 1 commits ) : nxrpswuq 01 d11519 descr_for_b
2023-01-12 22:53:26 +00:00
" ###);
// Now, let's fetch a2 and double-check that fetching a1 and b again doesn't do
// anything.
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok (
2023-01-12 22:53:26 +00:00
& target_jj_repo_path ,
2023-10-23 23:29:42 +00:00
& [ " git " , " fetch " , " --branch " , " b " , " --branch " , " glob:a* " ] ,
2023-01-12 22:53:26 +00:00
) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a2 @ origin [ updated ] tracked
2023-10-03 02:50:13 +00:00
Abandoned 1 commits that are no longer reachable .
2023-09-30 05:04:44 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ 31 c7d94b1f29 descr_for_a2 a2
│ │ ○ 01 d115196c39 descr_for_b b ? ? b @ origin
│ ├ ─ ╯
│ │ ○ 6 df2d34cf0da descr_for_a1 a1
│ ├ ─ ╯
│ ○ 2 bb3ebd2bba3 descr_for_trunk2
│ │ ○ 6 ebd41dc4f13 new_descr_for_b_to_create_conflict b ? ?
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & target_jj_repo_path ) , @ r ###"
2023-10-23 23:29:42 +00:00
a1 : ypowunwp 6 df2d34c descr_for_a1
@ origin : ypowunwp 6 df2d34c descr_for_a1
a2 : qrmzolkr 31 c7d94b descr_for_a2
@ origin : qrmzolkr 31 c7d94b descr_for_a2
2023-01-12 22:53:26 +00:00
b ( conflicted ) :
2023-10-24 01:43:12 +00:00
- vpupmnsl hidden c7d4bdcb descr_for_b
2023-10-23 23:29:42 +00:00
+ vpupmnsl 6 ebd41dc new_descr_for_b_to_create_conflict
+ nxrpswuq 01 d11519 descr_for_b
@ origin ( behind by 1 commits ) : nxrpswuq 01 d11519 descr_for_b
2023-01-12 22:53:26 +00:00
" ###);
}
2024-09-16 12:39:32 +00:00
#[ test ]
fn test_git_fetch_bookmarks_some_missing ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-09-16 12:39:32 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " origin " ) ;
add_git_remote ( & test_env , & repo_path , " rem1 " ) ;
add_git_remote ( & test_env , & repo_path , " rem2 " ) ;
// single missing bookmark, implicit remotes (@origin)
let ( _stdout , stderr ) =
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --branch " , " noexist " ] ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
Warning : No branch matching ` noexist ` found on any specified / configured remote
Nothing changed .
" ###);
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ " " ) ;
// multiple missing bookmarks, implicit remotes (@origin)
let ( _stdout , stderr ) = test_env . jj_cmd_ok (
& repo_path ,
& [
" git " , " fetch " , " --branch " , " noexist1 " , " --branch " , " noexist2 " ,
] ,
) ;
insta ::assert_snapshot! ( stderr , @ r ###"
Warning : No branch matching ` noexist1 ` found on any specified / configured remote
Warning : No branch matching ` noexist2 ` found on any specified / configured remote
Nothing changed .
" ###);
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ " " ) ;
// single existing bookmark, implicit remotes (@origin)
let ( _stdout , stderr ) = test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --branch " , " origin " ] ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
bookmark : origin @ origin [ new ] tracked
" ###);
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
origin : oputwtnw ffecd2d6 message
@ origin : oputwtnw ffecd2d6 message
" ###);
// multiple existing bookmark, explicit remotes, each bookmark is only in one
// remote.
let ( _stdout , stderr ) = test_env . jj_cmd_ok (
& repo_path ,
& [
" git " , " fetch " , " --branch " , " rem1 " , " --branch " , " rem2 " , " --remote " , " rem1 " , " --remote " ,
" rem2 " ,
] ,
) ;
insta ::assert_snapshot! ( stderr , @ r ###"
bookmark : rem1 @ rem1 [ new ] tracked
bookmark : rem2 @ rem2 [ new ] tracked
" ###);
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
origin : oputwtnw ffecd2d6 message
@ origin : oputwtnw ffecd2d6 message
rem1 : qxosxrvv 6 a211027 message
@ rem1 : qxosxrvv 6 a211027 message
rem2 : yszkquru 2497 a8a0 message
@ rem2 : yszkquru 2497 a8a0 message
" ###);
// multiple bookmarks, one exists, one doesn't
let ( _stdout , stderr ) = test_env . jj_cmd_ok (
& repo_path ,
& [
" git " , " fetch " , " --branch " , " rem1 " , " --branch " , " notexist " , " --remote " , " rem1 " ,
] ,
) ;
insta ::assert_snapshot! ( stderr , @ r ###"
Warning : No branch matching ` notexist ` found on any specified / configured remote
Nothing changed .
" ###);
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
origin : oputwtnw ffecd2d6 message
@ origin : oputwtnw ffecd2d6 message
rem1 : qxosxrvv 6 a211027 message
@ rem1 : qxosxrvv 6 a211027 message
rem2 : yszkquru 2497 a8a0 message
@ rem2 : yszkquru 2497 a8a0 message
" ###);
}
2023-06-01 03:55:46 +00:00
// See `test_undo_restore_commands.rs` for fetch-undo-push and fetch-undo-fetch
2024-08-21 19:59:15 +00:00
// of the same bookmarks for various kinds of undo.
2023-01-12 22:53:26 +00:00
#[ test ]
fn test_git_fetch_undo ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2023-01-12 22:53:26 +00:00
let source_git_repo_path = test_env . env_root ( ) . join ( " source " ) ;
let _git_repo = git2 ::Repository ::init ( source_git_repo_path . clone ( ) ) . unwrap ( ) ;
// Clone an empty repo. The target repo is a normal `jj` repo, *not* colocated
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " clone " , " source " , " target " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-01-12 22:53:26 +00:00
Fetching into new repo in " $TEST_ENV/target "
Nothing changed .
" ###);
let target_jj_repo_path = test_env . env_root ( ) . join ( " target " ) ;
let source_log =
2024-08-21 19:59:15 +00:00
create_colocated_repo_and_bookmarks_from_trunk1 ( & test_env , & source_git_repo_path ) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
@ c7d4bdcbc215 descr_for_b b
2024-07-15 22:20:10 +00:00
│ ○ decaa3966c83 descr_for_a2 a2
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 359 a9a02457d descr_for_a1 a1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Fetch 2 bookmarks
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok (
2023-01-12 22:53:26 +00:00
& target_jj_repo_path ,
& [ " git " , " fetch " , " --branch " , " b " , " --branch " , " a1 " ] ,
) ;
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ new ] tracked
bookmark : b @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " undo " ] ) ;
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-09-12 14:20:57 +00:00
insta ::assert_snapshot! ( stderr , @ r #"
2024-10-07 03:00:49 +00:00
Undid operation : eb2029853b02 ( 2001 - 02 - 03 08 :05 :18 ) fetch from git remote ( s ) origin
2024-09-12 14:20:57 +00:00
" #);
2023-01-12 22:53:26 +00:00
// The undo works as expected
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r ###"
@ 230 dd059e1b0
2024-07-15 22:20:10 +00:00
◆ 000000000000
2023-01-12 22:53:26 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Now try to fetch just one bookmark
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " , " --branch " , " b " ] ) ;
2023-01-12 22:53:26 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : b @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ ○ ff36dc55760e descr_for_trunk1
2023-01-12 22:53:26 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-01-12 22:53:26 +00:00
}
2023-02-24 17:24:48 +00:00
2023-06-01 03:55:46 +00:00
// Compare to `test_git_import_undo` in test_git_import_export
// TODO: Explain why these behaviors are useful
#[ test ]
fn test_fetch_undo_what ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2023-06-01 03:55:46 +00:00
let source_git_repo_path = test_env . env_root ( ) . join ( " source " ) ;
let _git_repo = git2 ::Repository ::init ( source_git_repo_path . clone ( ) ) . unwrap ( ) ;
// Clone an empty repo. The target repo is a normal `jj` repo, *not* colocated
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " clone " , " source " , " target " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-06-01 03:55:46 +00:00
Fetching into new repo in " $TEST_ENV/target "
Nothing changed .
" ###);
let repo_path = test_env . env_root ( ) . join ( " target " ) ;
let source_log =
2024-08-21 19:59:15 +00:00
create_colocated_repo_and_bookmarks_from_trunk1 ( & test_env , & source_git_repo_path ) ;
2023-06-01 03:55:46 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
@ c7d4bdcbc215 descr_for_b b
2024-07-15 22:20:10 +00:00
│ ○ decaa3966c83 descr_for_a2 a2
2023-06-01 03:55:46 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 359 a9a02457d descr_for_a1 a1
2023-06-01 03:55:46 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-06-01 03:55:46 +00:00
" ###);
// Initial state we will try to return to after `op restore`. There are no
2024-08-21 19:59:15 +00:00
// bookmarks.
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ " " ) ;
2023-08-21 00:34:49 +00:00
let base_operation_id = test_env . current_operation_id ( & repo_path ) ;
2023-06-01 03:55:46 +00:00
2024-08-21 19:59:15 +00:00
// Fetch a bookmark
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --branch " , " b " ] ) ;
2023-06-01 03:55:46 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : b @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ ○ ff36dc55760e descr_for_trunk1
2023-06-01 03:55:46 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
b : vpupmnsl c7d4bdcb descr_for_b
2023-10-18 06:12:17 +00:00
@ origin : vpupmnsl c7d4bdcb descr_for_b
2023-06-01 03:55:46 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// We can undo the change in the repo without moving the remote-tracking
// bookmark
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok (
2023-06-01 03:55:46 +00:00
& repo_path ,
& [ " op " , " restore " , " --what " , " repo " , & base_operation_id ] ,
) ;
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-09-25 06:52:11 +00:00
insta ::assert_snapshot! ( stderr , @ r #"
2024-10-07 03:00:49 +00:00
Restored to operation : eac759b9ab75 ( 2001 - 02 - 03 08 :05 :07 ) add workspace ' default '
2024-09-25 06:52:11 +00:00
" #);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-06-01 03:55:46 +00:00
b ( deleted )
2023-10-24 01:43:12 +00:00
@ origin : vpupmnsl hidden c7d4bdcb descr_for_b
2023-06-01 03:55:46 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Now, let's demo restoring just the remote-tracking bookmark. First, let's
2023-06-01 03:55:46 +00:00
// change our local repo state...
2024-08-21 19:59:15 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " bookmark " , " c " , " newbookmark " ] ) ;
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-06-01 03:55:46 +00:00
b ( deleted )
2023-10-24 01:43:12 +00:00
@ origin : vpupmnsl hidden c7d4bdcb descr_for_b
2024-08-21 19:59:15 +00:00
newbookmark : qpvuntsm 230 dd059 ( empty ) ( no description set )
2023-06-01 03:55:46 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Restoring just the remote-tracking state will not affect `newbookmark`, but
2023-06-01 03:55:46 +00:00
// will eliminate `b@origin`.
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok (
2023-06-01 03:55:46 +00:00
& repo_path ,
& [
" op " ,
" restore " ,
" --what " ,
" remote-tracking " ,
& base_operation_id ,
] ,
) ;
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-09-25 06:52:11 +00:00
insta ::assert_snapshot! ( stderr , @ r #"
2024-10-07 03:00:49 +00:00
Restored to operation : eac759b9ab75 ( 2001 - 02 - 03 08 :05 :07 ) add workspace ' default '
2024-09-25 06:52:11 +00:00
" #);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
newbookmark : qpvuntsm 230 dd059 ( empty ) ( no description set )
2023-06-01 03:55:46 +00:00
" ###);
}
2023-02-24 17:24:48 +00:00
#[ test ]
fn test_git_fetch_remove_fetch ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-24 17:24:48 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " origin " ) ;
2024-08-21 19:59:15 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " bookmark " , " create " , " origin " ] ) ;
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
origin : qpvuntsm 230 dd059 ( empty ) ( no description set )
2023-02-24 17:24:48 +00:00
" ###);
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-02-24 17:24:48 +00:00
origin ( conflicted ) :
2023-07-11 01:46:38 +00:00
+ qpvuntsm 230 dd059 ( empty ) ( no description set )
+ oputwtnw ffecd2d6 message
@ origin ( behind by 1 commits ) : oputwtnw ffecd2d6 message
2023-02-24 17:24:48 +00:00
" ###);
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " remote " , " remove " , " origin " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-02-24 17:24:48 +00:00
origin ( conflicted ) :
2023-07-11 01:46:38 +00:00
+ qpvuntsm 230 dd059 ( empty ) ( no description set )
+ oputwtnw ffecd2d6 message
2023-02-24 17:24:48 +00:00
" ###);
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " remote " , " add " , " origin " , " ../origin " ] ) ;
2023-02-24 17:24:48 +00:00
// Check that origin@origin is properly recreated
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2023-02-24 17:24:48 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : origin @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-02-24 17:24:48 +00:00
origin ( conflicted ) :
2023-07-11 01:46:38 +00:00
+ qpvuntsm 230 dd059 ( empty ) ( no description set )
+ oputwtnw ffecd2d6 message
@ origin ( behind by 1 commits ) : oputwtnw ffecd2d6 message
2023-02-24 17:24:48 +00:00
" ###);
}
2023-02-25 09:51:19 +00:00
#[ test ]
fn test_git_fetch_rename_fetch ( ) {
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-02-25 09:51:19 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
add_git_remote ( & test_env , & repo_path , " origin " ) ;
2024-08-21 19:59:15 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " bookmark " , " create " , " origin " ] ) ;
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
origin : qpvuntsm 230 dd059 ( empty ) ( no description set )
2023-02-25 09:51:19 +00:00
" ###);
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-02-25 09:51:19 +00:00
origin ( conflicted ) :
2023-07-11 01:46:38 +00:00
+ qpvuntsm 230 dd059 ( empty ) ( no description set )
+ oputwtnw ffecd2d6 message
@ origin ( behind by 1 commits ) : oputwtnw ffecd2d6 message
2023-02-25 09:51:19 +00:00
" ###);
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-02-25 09:51:19 +00:00
& repo_path ,
& [ " git " , " remote " , " rename " , " origin " , " upstream " ] ,
) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-02-25 09:51:19 +00:00
origin ( conflicted ) :
2023-07-11 01:46:38 +00:00
+ qpvuntsm 230 dd059 ( empty ) ( no description set )
+ oputwtnw ffecd2d6 message
@ upstream ( behind by 1 commits ) : oputwtnw ffecd2d6 message
2023-02-25 09:51:19 +00:00
" ###);
// Check that jj indicates that nothing has changed
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --remote " , " upstream " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-02-25 09:51:19 +00:00
Nothing changed .
" ###);
}
2023-02-26 14:23:04 +00:00
#[ test ]
2024-08-21 19:59:15 +00:00
fn test_git_fetch_removed_bookmark ( ) {
2023-02-26 14:23:04 +00:00
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2023-02-26 14:23:04 +00:00
let source_git_repo_path = test_env . env_root ( ) . join ( " source " ) ;
let _git_repo = git2 ::Repository ::init ( source_git_repo_path . clone ( ) ) . unwrap ( ) ;
// Clone an empty repo. The target repo is a normal `jj` repo, *not* colocated
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " clone " , " source " , " target " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-02-26 14:23:04 +00:00
Fetching into new repo in " $TEST_ENV/target "
Nothing changed .
" ###);
let target_jj_repo_path = test_env . env_root ( ) . join ( " target " ) ;
let source_log =
2024-08-21 19:59:15 +00:00
create_colocated_repo_and_bookmarks_from_trunk1 ( & test_env , & source_git_repo_path ) ;
2023-02-26 14:23:04 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
@ c7d4bdcbc215 descr_for_b b
2024-07-15 22:20:10 +00:00
│ ○ decaa3966c83 descr_for_a2 a2
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 359 a9a02457d descr_for_a1 a1
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-02-26 14:23:04 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Fetch all bookmarks
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " ] ) ;
2023-02-26 14:23:04 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ new ] tracked
bookmark : a2 @ origin [ new ] tracked
bookmark : b @ origin [ new ] tracked
bookmark : trunk1 @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1 trunk1
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-02-26 14:23:04 +00:00
2024-08-21 19:59:15 +00:00
// Remove a2 bookmark in origin
test_env . jj_cmd_ok ( & source_git_repo_path , & [ " bookmark " , " forget " , " a2 " ] ) ;
2023-02-26 14:23:04 +00:00
2024-08-21 19:59:15 +00:00
// Fetch bookmark a1 from origin and check that a2 is still there
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " , " --branch " , " a1 " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-02-26 14:23:04 +00:00
Nothing changed .
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1 trunk1
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-02-26 14:23:04 +00:00
2024-08-21 19:59:15 +00:00
// Fetch bookmarks a2 from origin, and check that it has been removed locally
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " , " --branch " , " a2 " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a2 @ origin [ deleted ] untracked
2023-10-03 02:50:13 +00:00
Abandoned 1 commits that are no longer reachable .
2023-09-30 05:04:44 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1 trunk1
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-02-26 14:23:04 +00:00
}
#[ test ]
2024-08-21 19:59:15 +00:00
fn test_git_fetch_removed_parent_bookmark ( ) {
2023-02-26 14:23:04 +00:00
let test_env = TestEnvironment ::default ( ) ;
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2023-02-26 14:23:04 +00:00
let source_git_repo_path = test_env . env_root ( ) . join ( " source " ) ;
let _git_repo = git2 ::Repository ::init ( source_git_repo_path . clone ( ) ) . unwrap ( ) ;
// Clone an empty repo. The target repo is a normal `jj` repo, *not* colocated
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) =
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " clone " , " source " , " target " ] ) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2023-02-26 14:23:04 +00:00
Fetching into new repo in " $TEST_ENV/target "
Nothing changed .
" ###);
let target_jj_repo_path = test_env . env_root ( ) . join ( " target " ) ;
let source_log =
2024-08-21 19:59:15 +00:00
create_colocated_repo_and_bookmarks_from_trunk1 ( & test_env , & source_git_repo_path ) ;
2023-02-26 14:23:04 +00:00
insta ::assert_snapshot! ( source_log , @ r ###"
= = = = = Source git repo contents = = = = =
@ c7d4bdcbc215 descr_for_b b
2024-07-15 22:20:10 +00:00
│ ○ decaa3966c83 descr_for_a2 a2
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
│ ○ 359 a9a02457d descr_for_a1 a1
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
○ ff36dc55760e descr_for_trunk1 trunk1
◆ 000000000000
2023-02-26 14:23:04 +00:00
" ###);
2024-08-21 19:59:15 +00:00
// Fetch all bookmarks
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok ( & target_jj_repo_path , & [ " git " , " fetch " ] ) ;
2023-02-26 14:23:04 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
2024-02-13 22:17:05 +00:00
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ new ] tracked
bookmark : a2 @ origin [ new ] tracked
bookmark : b @ origin [ new ] tracked
bookmark : trunk1 @ origin [ new ] tracked
2024-02-13 22:17:05 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ │ ○ 359 a9a02457d descr_for_a1 a1
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1 trunk1
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-02-26 14:23:04 +00:00
2024-08-21 19:59:15 +00:00
// Remove all bookmarks in origin.
test_env . jj_cmd_ok ( & source_git_repo_path , & [ " bookmark " , " forget " , " glob:* " ] ) ;
2023-02-26 14:23:04 +00:00
2024-08-21 19:59:15 +00:00
// Fetch bookmarks master, trunk1 and a1 from origin and check that only those
// bookmarks have been removed and that others were not rebased because of
2023-02-26 14:23:04 +00:00
// abandoned commits.
2023-10-10 11:59:18 +00:00
let ( stdout , stderr ) = test_env . jj_cmd_ok (
2023-02-26 14:23:04 +00:00
& target_jj_repo_path ,
& [
" git " , " fetch " , " --branch " , " master " , " --branch " , " trunk1 " , " --branch " , " a1 " ,
] ,
) ;
2023-10-10 11:07:06 +00:00
insta ::assert_snapshot! ( stdout , @ " " ) ;
insta ::assert_snapshot! ( stderr , @ r ###"
2024-09-11 16:11:50 +00:00
bookmark : a1 @ origin [ deleted ] untracked
bookmark : trunk1 @ origin [ deleted ] untracked
2023-10-03 02:50:13 +00:00
Abandoned 1 commits that are no longer reachable .
2024-09-16 12:39:32 +00:00
Warning : No branch matching ` master ` found on any specified / configured remote
2023-09-30 05:04:44 +00:00
" ###);
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & target_jj_repo_path ) , @ r #"
@ 230 dd059e1b0
│ ○ c7d4bdcbc215 descr_for_b b
│ │ ○ decaa3966c83 descr_for_a2 a2
│ ├ ─ ╯
│ ○ ff36dc55760e descr_for_trunk1
2023-02-26 14:23:04 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2023-02-26 14:23:04 +00:00
}
2023-06-20 00:44:11 +00:00
#[ test ]
2024-08-21 19:59:15 +00:00
fn test_git_fetch_remote_only_bookmark ( ) {
2023-06-20 00:44:11 +00:00
let test_env = TestEnvironment ::default ( ) ;
2024-05-17 19:49:25 +00:00
test_env . jj_cmd_ok ( test_env . env_root ( ) , & [ " git " , " init " , " repo " ] ) ;
2023-06-20 00:44:11 +00:00
let repo_path = test_env . env_root ( ) . join ( " repo " ) ;
// Create non-empty git repo to add as a remote
let git_repo_path = test_env . env_root ( ) . join ( " git-repo " ) ;
let git_repo = git2 ::Repository ::init ( git_repo_path ) . unwrap ( ) ;
let signature =
git2 ::Signature ::new ( " Some One " , " some.one@example.com " , & git2 ::Time ::new ( 0 , 0 ) ) . unwrap ( ) ;
let mut tree_builder = git_repo . treebuilder ( None ) . unwrap ( ) ;
let file_oid = git_repo . blob ( b " content " ) . unwrap ( ) ;
tree_builder
. insert ( " file " , file_oid , git2 ::FileMode ::Blob . into ( ) )
. unwrap ( ) ;
let tree_oid = tree_builder . write ( ) . unwrap ( ) ;
let tree = git_repo . find_tree ( tree_oid ) . unwrap ( ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok (
2023-06-20 00:44:11 +00:00
& repo_path ,
& [ " git " , " remote " , " add " , " origin " , " ../git-repo " ] ,
) ;
2024-08-21 19:59:15 +00:00
// Create a commit and a bookmark in the git repo
2023-06-20 00:44:11 +00:00
git_repo
. commit (
Some ( " refs/heads/feature1 " ) ,
& signature ,
& signature ,
" message " ,
& tree ,
& [ ] ,
)
. unwrap ( ) ;
2024-08-21 19:59:15 +00:00
// Fetch using git.auto_local_bookmark = true
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = true " ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --remote=origin " ] ) ;
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
feature1 : mzyxwzks 9 f01a0e0 message
2023-10-18 06:12:17 +00:00
@ origin : mzyxwzks 9 f01a0e0 message
2023-06-20 00:44:11 +00:00
" ###);
git_repo
. commit (
Some ( " refs/heads/feature2 " ) ,
& signature ,
& signature ,
" message " ,
& tree ,
& [ ] ,
)
. unwrap ( ) ;
2024-08-21 19:59:15 +00:00
// Fetch using git.auto_local_bookmark = false
2024-10-30 04:36:31 +00:00
test_env . add_config ( " git.auto-local-bookmark = false " ) ;
2023-10-10 11:59:18 +00:00
test_env . jj_cmd_ok ( & repo_path , & [ " git " , " fetch " , " --remote=origin " ] ) ;
2024-09-21 06:01:33 +00:00
insta ::assert_snapshot! ( get_log_output ( & test_env , & repo_path ) , @ r #"
@ 230 dd059e1b0
│ ◆ 9 f01a0e04879 message feature1 feature2 @ origin
2023-10-11 20:58:08 +00:00
├ ─ ╯
2024-07-15 22:20:10 +00:00
◆ 000000000000
2024-09-21 06:01:33 +00:00
" #);
2024-08-21 19:59:15 +00:00
insta ::assert_snapshot! ( get_bookmark_output ( & test_env , & repo_path ) , @ r ###"
2023-07-11 01:46:38 +00:00
feature1 : mzyxwzks 9 f01a0e0 message
2023-10-18 06:12:17 +00:00
@ origin : mzyxwzks 9 f01a0e0 message
2023-10-11 20:58:08 +00:00
feature2 @ origin : mzyxwzks 9 f01a0e0 message
2023-06-20 00:44:11 +00:00
" ###);
}