@@ -94,21 +94,27 @@ def inject_hook(self, content: list[str], force: bool = False):
9494async def init (configs : Config ) -> int :
9595 assert configs .project_root is not None
9696 project_config_dir = os .path .join (str (configs .project_root ), ".vectorcode" )
97+ is_initialised = 0
9798 if os .path .isdir (project_config_dir ) and not configs .force :
9899 logger .warning (
99100 f"{ configs .project_root } is already initialised for VectorCode." ,
100101 )
101- return 1
102-
103- os .makedirs (project_config_dir , exist_ok = True )
104- for item in ("config.json" , "vectorcode.include" , "vectorcode.exclude" ):
105- local_file_path = os .path .join (project_config_dir , item )
106- global_file_path = os .path .join (
107- os .path .expanduser ("~" ), ".config" , "vectorcode" , item
102+ is_initialised = 1
103+ else :
104+ os .makedirs (project_config_dir , exist_ok = True )
105+ for item in ("config.json" , "vectorcode.include" , "vectorcode.exclude" ):
106+ local_file_path = os .path .join (project_config_dir , item )
107+ global_file_path = os .path .join (
108+ os .path .expanduser ("~" ), ".config" , "vectorcode" , item
109+ )
110+ if os .path .isfile (global_file_path ):
111+ logger .debug (f"Copying global { item } to { project_config_dir } " )
112+ shutil .copyfile (global_file_path , local_file_path )
113+
114+ print (f"VectorCode project root has been initialised at { configs .project_root } " )
115+ print (
116+ "Note: The collection in the database will not be created until you vectorise a file."
108117 )
109- if os .path .isfile (global_file_path ):
110- logger .debug (f"Copying global { item } to { project_config_dir } " )
111- shutil .copyfile (global_file_path , local_file_path )
112118
113119 git_root = find_project_root (configs .project_root , ".git" )
114120 if git_root :
@@ -120,8 +126,4 @@ async def init(configs: Config) -> int:
120126 hook_obj = HookFile (hook_file_path , git_dir = git_root )
121127 hook_obj .inject_hook (__HOOK_CONTENTS [hook ], configs .force )
122128
123- print (f"VectorCode project root has been initialised at { configs .project_root } " )
124- print (
125- "Note: The collection in the database will not be created until you vectorise a file."
126- )
127- return 0
129+ return is_initialised
0 commit comments