@@ -9,7 +9,6 @@ use git2::Repository as GitRepository;
99
1010const WORKTREE_IGNORE_ENTRY : & str = ".rsworktree/" ;
1111const WORKTREE_IGNORE_ALT_ENTRY : & str = ".rsworktree" ;
12- const DEFAULT_EDITOR_COMMAND : & str = "vim" ;
1312
1413pub struct Repo {
1514 git : GitRepository ,
@@ -71,7 +70,6 @@ impl Repo {
7170 let dir = self . worktrees_dir ( ) ;
7271 fs:: create_dir_all ( & dir)
7372 . wrap_err_with ( || eyre:: eyre!( "failed to create `{}`" , dir. display( ) ) ) ?;
74- self . ensure_default_preferences_file ( & dir) ?;
7573 Ok ( dir)
7674 }
7775
@@ -111,27 +109,6 @@ impl Repo {
111109
112110 Ok ( ( ) )
113111 }
114-
115- fn ensure_default_preferences_file ( & self , dir : & Path ) -> color_eyre:: Result < ( ) > {
116- let config_path = dir. join ( crate :: editor:: CONFIG_FILE_NAME ) ;
117-
118- if config_path. exists ( ) {
119- return Ok ( ( ) ) ;
120- }
121-
122- let contents = serde_json:: to_string_pretty ( & serde_json:: json!( {
123- "editor" : {
124- "command" : DEFAULT_EDITOR_COMMAND
125- }
126- } ) )
127- . wrap_err ( "failed to serialize default preferences" ) ?;
128-
129- fs:: write ( & config_path, format ! ( "{contents}\n " ) ) . wrap_err_with ( || {
130- eyre:: eyre!( "failed to write `{}`" , config_path. display( ) )
131- } ) ?;
132-
133- Ok ( ( ) )
134- }
135112}
136113
137114fn gitignore_has_entry ( contents : & str ) -> bool {
@@ -146,7 +123,6 @@ mod tests {
146123 use super :: * ;
147124 use std:: fs;
148125
149- use serde_json:: Value ;
150126 use tempfile:: TempDir ;
151127
152128 fn init_repo ( dir : & TempDir ) -> color_eyre:: Result < Repo > {
@@ -203,45 +179,6 @@ mod tests {
203179 Ok ( ( ) )
204180 }
205181
206- #[ test]
207- fn ensure_worktrees_dir_creates_default_preferences_file ( ) -> color_eyre:: Result < ( ) > {
208- let dir = TempDir :: new ( ) ?;
209- let repo = init_repo ( & dir) ?;
210-
211- repo. ensure_worktrees_dir ( ) ?;
212-
213- let config_path = repo. worktrees_dir ( ) . join ( crate :: editor:: CONFIG_FILE_NAME ) ;
214- let contents = fs:: read_to_string ( & config_path) ?;
215- let parsed: Value = serde_json:: from_str ( & contents) ?;
216-
217- assert_eq ! (
218- parsed
219- . get( "editor" )
220- . and_then( |value| value. get( "command" ) )
221- . and_then( Value :: as_str) ,
222- Some ( DEFAULT_EDITOR_COMMAND )
223- ) ;
224-
225- Ok ( ( ) )
226- }
227-
228- #[ test]
229- fn ensure_worktrees_dir_preserves_existing_preferences_file ( ) -> color_eyre:: Result < ( ) > {
230- let dir = TempDir :: new ( ) ?;
231- let repo = init_repo ( & dir) ?;
232- let worktrees_dir = repo. worktrees_dir ( ) ;
233- fs:: create_dir_all ( & worktrees_dir) ?;
234- let config_path = worktrees_dir. join ( crate :: editor:: CONFIG_FILE_NAME ) ;
235- fs:: write ( & config_path, r#"{"editor":{"command":"code"}}"# ) ?;
236-
237- repo. ensure_worktrees_dir ( ) ?;
238-
239- let contents = fs:: read_to_string ( & config_path) ?;
240- assert_eq ! ( contents, r#"{"editor":{"command":"code"}}"# ) ;
241-
242- Ok ( ( ) )
243- }
244-
245182 #[ test]
246183 fn gitignore_has_entry_detects_alternate_form ( ) {
247184 assert ! ( gitignore_has_entry( ".rsworktree\n " ) ) ;
0 commit comments