@@ -7,8 +7,8 @@ use gitbutler_command_context::CommandContext;
77use gitbutler_repo:: logging:: { LogUntil , RepositoryExt as _} ;
88use gitbutler_repo_actions:: RepoActionsExt ;
99use gitbutler_stack:: stack_context:: CommandContextExt ;
10+ use gitbutler_stack:: PatchReferenceUpdate ;
1011use gitbutler_stack:: { CommitOrChangeId , StackBranch , VirtualBranchesHandle } ;
11- use gitbutler_stack:: { PatchReferenceUpdate , TargetUpdate } ;
1212use itertools:: Itertools ;
1313use tempfile:: TempDir ;
1414
@@ -381,7 +381,6 @@ fn update_branch_name_fails_validation() -> Result<()> {
381381 let mut test_ctx = test_ctx ( & ctx) ?;
382382 let update = PatchReferenceUpdate {
383383 name : Some ( "invalid name" . into ( ) ) ,
384- target_update : None ,
385384 description : None ,
386385 } ;
387386 let result = test_ctx
@@ -397,7 +396,6 @@ fn update_branch_name_success() -> Result<()> {
397396 let mut test_ctx = test_ctx ( & ctx) ?;
398397 let update = PatchReferenceUpdate {
399398 name : Some ( "new-name" . into ( ) ) ,
400- target_update : None ,
401399 description : None ,
402400 } ;
403401 let result = test_ctx
@@ -424,7 +422,6 @@ fn update_branch_name_resets_pr_number() -> Result<()> {
424422 assert_eq ! ( test_ctx. stack. heads[ 0 ] . pr_number, Some ( pr_number) ) ;
425423 let update = PatchReferenceUpdate {
426424 name : Some ( "new-name" . into ( ) ) ,
427- target_update : None ,
428425 description : None ,
429426 } ;
430427 test_ctx
@@ -444,7 +441,6 @@ fn update_series_set_description() -> Result<()> {
444441 let mut test_ctx = test_ctx ( & ctx) ?;
445442 let update = PatchReferenceUpdate {
446443 name : None ,
447- target_update : None ,
448444 description : Some ( Some ( "my description" . into ( ) ) ) ,
449445 } ;
450446 let result = test_ctx
@@ -463,96 +459,6 @@ fn update_series_set_description() -> Result<()> {
463459 Ok ( ( ) )
464460}
465461
466- #[ test]
467- fn update_series_target_fails_commit_not_in_stack ( ) -> Result < ( ) > {
468- let ( ctx, _temp_dir) = command_ctx ( "multiple-commits" ) ?;
469- let mut test_ctx = test_ctx ( & ctx) ?;
470- let other_commit_id = test_ctx. other_commits . last ( ) . unwrap ( ) . id ( ) . to_string ( ) ;
471- let update = PatchReferenceUpdate {
472- name : None ,
473- target_update : Some ( TargetUpdate {
474- target : CommitOrChangeId :: CommitId ( other_commit_id. clone ( ) ) ,
475- preceding_head_name : None ,
476- } ) ,
477- description : None ,
478- } ;
479- let result = test_ctx
480- . stack
481- . update_branch ( & ctx, "a-branch-2" . into ( ) , & update) ;
482- assert_eq ! (
483- result. err( ) . unwrap( ) . to_string( ) ,
484- format!(
485- "The commit {} is not between the stack head and the stack base" ,
486- other_commit_id
487- )
488- ) ;
489- Ok ( ( ) )
490- }
491-
492- #[ test]
493- fn update_series_target_orphan_commit_fails ( ) -> Result < ( ) > {
494- let ( ctx, _temp_dir) = command_ctx ( "multiple-commits" ) ?;
495- let mut test_ctx = test_ctx ( & ctx) ?;
496- let initial_state = test_ctx. stack . heads . clone ( ) ;
497- let first_commit_id = test_ctx. commits . first ( ) . unwrap ( ) . id ( ) . to_string ( ) ;
498- let update = PatchReferenceUpdate {
499- name : Some ( "new-lol" . into ( ) ) ,
500- target_update : Some ( TargetUpdate {
501- target : CommitOrChangeId :: CommitId ( first_commit_id. clone ( ) ) ,
502- preceding_head_name : None ,
503- } ) ,
504- description : None ,
505- } ;
506- let result = test_ctx
507- . stack
508- . update_branch ( & ctx, "a-branch-2" . into ( ) , & update) ;
509-
510- assert_eq ! (
511- result. err( ) . unwrap( ) . to_string( ) ,
512- "This update would cause orphaned patches, which is disallowed"
513- ) ;
514- assert_eq ! ( initial_state, test_ctx. stack. heads) ; // no change due to failure
515- Ok ( ( ) )
516- }
517-
518- #[ test]
519- fn update_series_target_success ( ) -> Result < ( ) > {
520- let ( ctx, _temp_dir) = command_ctx ( "multiple-commits" ) ?;
521- let mut test_ctx = test_ctx ( & ctx) ?;
522- let commit_0_change_id = CommitOrChangeId :: CommitId ( test_ctx. commits [ 0 ] . id ( ) . to_string ( ) ) ;
523- let repo = & ctx. gix_repository ( ) ?;
524- let series_1 = StackBranch :: new ( commit_0_change_id. clone ( ) , "series_1" . into ( ) , None , repo) ?;
525- let result = test_ctx. stack . add_series ( & ctx, series_1, None ) ;
526- assert ! ( result. is_ok( ) ) ;
527- assert_eq ! (
528- commit_0_change_id,
529- test_ctx. stack. heads[ 0 ] . head_oid( repo) ?. into( )
530- ) ;
531- let commit_1_change_id = CommitOrChangeId :: CommitId ( test_ctx. commits [ 1 ] . id ( ) . to_string ( ) ) ;
532- let update = PatchReferenceUpdate {
533- name : None ,
534- target_update : Some ( TargetUpdate {
535- target : commit_1_change_id. clone ( ) ,
536- preceding_head_name : None ,
537- } ) ,
538- description : None ,
539- } ;
540- let result = test_ctx
541- . stack
542- . update_branch ( & ctx, "series_1" . into ( ) , & update) ;
543- assert ! ( result. is_ok( ) ) ;
544- assert_eq ! (
545- commit_1_change_id,
546- test_ctx. stack. heads[ 0 ] . head_oid( repo) ?. into( )
547- ) ;
548- // Assert persisted
549- assert_eq ! (
550- test_ctx. stack,
551- test_ctx. handle. get_stack( test_ctx. stack. id) ?
552- ) ;
553- Ok ( ( ) )
554- }
555-
556462#[ test]
557463fn push_series_success ( ) -> Result < ( ) > {
558464 let ( ctx, _temp_dir) = command_ctx ( "multiple-commits" ) ?;
0 commit comments