@@ -14,15 +14,14 @@ use crate::{
14
14
execute_command, get_single_selection,
15
15
marks:: { marks_command, MarksCommand } ,
16
16
picker:: Preview ,
17
- repos:: Prunable ,
17
+ repos:: RepoProvider ,
18
18
session:: { create_sessions, SessionContainer } ,
19
19
tmux:: Tmux ,
20
20
Result , TmsError ,
21
21
} ;
22
22
use clap:: { Args , Parser , Subcommand } ;
23
23
use clap_complete:: { ArgValueCandidates , CompletionCandidate } ;
24
24
use error_stack:: ResultExt ;
25
- use gix:: Repository ;
26
25
use ratatui:: style:: Color ;
27
26
28
27
#[ derive( Debug , Parser ) ]
@@ -230,7 +229,7 @@ impl Cli {
230
229
Ok ( SubCommandGiven :: Yes )
231
230
}
232
231
Some ( CliCommand :: Refresh ( args) ) => {
233
- refresh_command ( args, tmux) ?;
232
+ refresh_command ( args, config , tmux) ?;
234
233
Ok ( SubCommandGiven :: Yes )
235
234
}
236
235
@@ -610,7 +609,7 @@ fn rename_subcommand(args: &RenameCommand, tmux: &Tmux) -> Result<()> {
610
609
Ok ( ( ) )
611
610
}
612
611
613
- fn refresh_command ( args : & RefreshCommand , tmux : & Tmux ) -> Result < ( ) > {
612
+ fn refresh_command ( args : & RefreshCommand , config : Config , tmux : & Tmux ) -> Result < ( ) > {
614
613
let session_name = args
615
614
. name
616
615
. clone ( )
@@ -629,11 +628,11 @@ fn refresh_command(args: &RefreshCommand, tmux: &Tmux) -> Result<()> {
629
628
. map ( |line| line. replace ( '\'' , "" ) )
630
629
. collect ( ) ;
631
630
632
- if let Ok ( repository) = gix :: open ( & session_path) {
631
+ if let Ok ( repository) = RepoProvider :: open ( Path :: new ( & session_path) , & config ) {
633
632
let mut num_worktree_windows = 0 ;
634
- if let Ok ( worktrees) = repository. worktrees ( ) {
633
+ if let Ok ( worktrees) = repository. worktrees ( & config ) {
635
634
for worktree in worktrees. iter ( ) {
636
- let worktree_name = worktree. id ( ) . to_string ( ) ;
635
+ let worktree_name = worktree. name ( ) ;
637
636
if existing_window_names. contains ( & worktree_name) {
638
637
num_worktree_windows += 1 ;
639
638
continue ;
@@ -645,12 +644,7 @@ fn refresh_command(args: &RefreshCommand, tmux: &Tmux) -> Result<()> {
645
644
num_worktree_windows += 1 ;
646
645
tmux. new_window (
647
646
Some ( & worktree_name) ,
648
- Some (
649
- & worktree
650
- . base ( )
651
- . change_context ( TmsError :: GitError ) ?
652
- . to_string ( ) ?,
653
- ) ,
647
+ Some ( & worktree. path ( ) ?. to_string ( ) ?) ,
654
648
Some ( & session_name) ,
655
649
) ;
656
650
}
@@ -713,13 +707,11 @@ fn clone_repo_command(args: &CloneRepoCommand, config: Config, tmux: &Tmux) -> R
713
707
714
708
let previous_session = tmux. current_session ( "#{session_name}" ) ;
715
709
716
- let repo = git_clone ( & args. repository , & path) ?;
710
+ let repo = RepoProvider :: open ( git_clone ( & args. repository , & path) ? , & config ) ?;
717
711
718
712
let mut session_name = repo_name. to_string ( ) ;
719
713
720
- let switch_config = config. clone_repo_switch . unwrap_or_default ( ) ;
721
-
722
- let switch = match switch_config {
714
+ let switch = match config. clone_repo_switch . unwrap_or_default ( ) {
723
715
CloneRepoSwitchConfig :: Always => true ,
724
716
CloneRepoSwitchConfig :: Never => false ,
725
717
CloneRepoSwitchConfig :: Foreground => {
@@ -741,15 +733,15 @@ fn clone_repo_command(args: &CloneRepoCommand, config: Config, tmux: &Tmux) -> R
741
733
}
742
734
743
735
tmux. new_session ( Some ( & session_name) , Some ( & path. display ( ) . to_string ( ) ) ) ;
744
- tmux. set_up_tmux_env ( & repo, & session_name) ?;
736
+ tmux. set_up_tmux_env ( & repo, & session_name, & config ) ?;
745
737
if switch {
746
738
tmux. switch_to_session ( & session_name) ;
747
739
}
748
740
749
741
Ok ( ( ) )
750
742
}
751
743
752
- fn git_clone ( repo : & str , target : & Path ) -> Result < Repository > {
744
+ fn git_clone < ' a > ( repo : & str , target : & ' a Path ) -> Result < & ' a Path > {
753
745
std:: fs:: create_dir_all ( target) . change_context ( TmsError :: IoError ) ?;
754
746
let mut cmd = Command :: new ( "git" )
755
747
. current_dir ( target. parent ( ) . ok_or ( TmsError :: IoError ) ?)
@@ -760,8 +752,7 @@ fn git_clone(repo: &str, target: &Path) -> Result<Repository> {
760
752
. change_context ( TmsError :: GitError ) ?;
761
753
762
754
cmd. wait ( ) . change_context ( TmsError :: GitError ) ?;
763
- let repo = gix:: open ( target) . change_context ( TmsError :: GitError ) ?;
764
- Ok ( repo)
755
+ Ok ( target)
765
756
}
766
757
767
758
fn init_repo_command ( args : & InitRepoCommand , config : Config , tmux : & Tmux ) -> Result < ( ) > {
@@ -771,6 +762,7 @@ fn init_repo_command(args: &InitRepoCommand, config: Config, tmux: &Tmux) -> Res
771
762
path. push ( & args. repository ) ;
772
763
773
764
let repo = gix:: init ( & path) . change_context ( TmsError :: GitError ) ?;
765
+ let repo = RepoProvider :: Git ( repo) ;
774
766
775
767
let mut session_name = args. repository . to_string ( ) ;
776
768
@@ -787,7 +779,7 @@ fn init_repo_command(args: &InitRepoCommand, config: Config, tmux: &Tmux) -> Res
787
779
}
788
780
789
781
tmux. new_session ( Some ( & session_name) , Some ( & path. display ( ) . to_string ( ) ) ) ;
790
- tmux. set_up_tmux_env ( & repo, & session_name) ?;
782
+ tmux. set_up_tmux_env ( & repo, & session_name, & config ) ?;
791
783
tmux. switch_to_session ( & session_name) ;
792
784
793
785
Ok ( ( ) )
0 commit comments