File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,15 +50,16 @@ def create_repository(workspace):
5050 os .mkdir (workspace )
5151 os .chdir (workspace )
5252
53- os .mkdir (GIT_DIR )
53+ if not os .path .exists (GIT_DIR ):
54+ os .mkdir (GIT_DIR )
5455
55- for new_dir in INIT_DIR :
56- os .mkdir (new_dir )
56+ for new_dir in INIT_DIR :
57+ os .mkdir (new_dir )
5758
58- for file_and_content in INIT_FILE :
59- file_name = file_and_content [0 ]
60- content = file_and_content [1 ]
61- write_to_file (file_name , content )
59+ for file_and_content in INIT_FILE :
60+ file_name = file_and_content [0 ]
61+ content = file_and_content [1 ]
62+ write_to_file (file_name , content )
6263
6364
6465 init_config_dict = {
Original file line number Diff line number Diff line change @@ -35,6 +35,18 @@ def test_init_without_workspace(self):
3535 self ._check_dirs_and_files (workspace )
3636 shutil .rmtree (GIT_DIR )
3737
38+ def test_init_in_existing_repository (self ):
39+ workspace = "test"
40+ Command .cmd_init (workspace )
41+ os .chdir ('..' )
42+ try :
43+ Command .cmd_init (workspace )
44+ except OSError :
45+ self .assertEqual (1 , 2 , "Reinitialized existing repository failed" )
46+ finally :
47+ os .chdir ('..' )
48+ shutil .rmtree (workspace )
49+
3850
3951if __name__ == "__main__" :
4052 unittest .main ()
You can’t perform that action at this time.
0 commit comments