File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1- use std:: { fs:: OpenOptions , io:: Write , process:: Command } ;
1+ use std:: { fs:: OpenOptions , io:: Write , process:: Command , sync :: Mutex } ;
22
33use crate :: get_version_control;
44
55use anyhow:: Result ;
6+ use once_cell:: sync:: Lazy ;
67use tempfile:: TempDir ;
78
9+ // Global mutex to prevent race conditions when changing current directory
10+ // This is the same pattern used in Sapling tests
11+ static GIT_GLOBAL_MUTEX : Lazy < Mutex < ( ) > > = Lazy :: new ( Mutex :: default) ;
12+
813pub struct GitCheckout {
914 root : TempDir ,
1015}
@@ -81,6 +86,7 @@ impl GitCheckout {
8186 }
8287
8388 pub fn changed_files ( & self , relative_to : Option < & str > ) -> Result < Vec < String > > {
89+ let _shared = GIT_GLOBAL_MUTEX . lock ( ) . unwrap ( ) ;
8490 std:: env:: set_current_dir ( self . root ( ) ) ?;
8591 let repo = get_version_control ( ) ?;
8692 let files = repo. get_changed_files ( relative_to) ?;
@@ -92,6 +98,7 @@ impl GitCheckout {
9298 }
9399
94100 pub fn merge_base_with ( & self , merge_base_with : & str ) -> Result < String > {
101+ let _shared = GIT_GLOBAL_MUTEX . lock ( ) . unwrap ( ) ;
95102 std:: env:: set_current_dir ( self . root ( ) ) ?;
96103 let repo = get_version_control ( ) ?;
97104 repo. get_merge_base_with ( merge_base_with)
You can’t perform that action at this time.
0 commit comments