22
33import asyncio
44import shutil
5- import os
65from dataclasses import dataclass , field
76from enum import Enum
87from pathlib import Path
@@ -60,25 +59,30 @@ def path(self) -> str:
6059
6160 def init (self ) -> None :
6261 self .dst_directory .mkdir (parents = True , exist_ok = True )
63- os .chmod (self .dst_directory , 0o777 )
64-
62+
6563 dest_path = self .dst_directory / self .name
6664 if dest_path .exists ():
6765 shutil .rmtree (dest_path )
68-
66+
6967 dest = shutil .copytree (
7068 src = self .src_directory ,
7169 dst = dest_path ,
7270 ignore = shutil .ignore_patterns (".git" , * self .directories_to_ignore ),
7371 )
74-
72+ dest_path . chmod ( 0o755 )
7573 print (dest )
7674
77- self ._repo = GitRepoManager (str (Path (self .dst_directory / self .name )), branch = self .initial_branch )
75+ porcelain .init (str (dest_path ))
76+ repo = porcelain .open_repo (str (dest_path ))
7877
79- files = list (
80- porcelain .get_untracked_paths (self ._repo .git .path , self ._repo .git .path , self ._repo .git .open_index ())
81- )
78+ config = repo .get_config ()
79+ config .set (("user" ,), "name" , "Infrahub Test" )
80+ config .
set ((
"user" ,),
"email" ,
"[email protected] " )
81+ config .write_to_path ()
82+
83+ self ._repo = GitRepoManager (str (dest_path ), branch = self .initial_branch )
84+
85+ files = list (porcelain .get_untracked_paths (self ._repo .git .path , self ._repo .git .path , repo .open_index ()))
8286 print (files )
8387 files_to_add = [str (Path (self ._repo .git .path ) / t ) for t in files ]
8488 print (files_to_add )
@@ -88,11 +92,19 @@ def init(self) -> None:
8892 porcelain .checkout_branch (self ._repo .git , self .initial_branch .encode ("utf-8" ))
8993
9094 async def add_to_infrahub (self , client : InfrahubClient , branch : str | None = None ) -> dict :
95+ repo_path = Path (self .remote_directory_name ) / self .name
96+ print (f"Repository path: { repo_path } " )
97+
9198 input_data = {
9299 "data" : {
93100 "name" : {"value" : self .name },
94- "location" : {"value" : f"{ self .remote_directory_name } /{ self .name } " },
95- },
101+ "location" : {"value" : str (repo_path )},
102+ "git" : {
103+ "branch" : {"value" : self .initial_branch },
104+ "credentials" : {"type" : {"value" : "none" }},
105+ "options" : {"bare" : {"value" : False }},
106+ },
107+ }
96108 }
97109
98110 query = Mutation (
0 commit comments