Skip to content

Commit 0aae68c

Browse files
committed
test better initial git
1 parent 7238195 commit 0aae68c

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

infrahub_sdk/testing/repository.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,19 @@ def init(self) -> None:
7171
)
7272
dest_path.chmod(0o755)
7373
print(dest)
74+
75+
porcelain.init(str(dest_path))
76+
repo = porcelain.open_repo(str(dest_path))
7477

75-
self._repo = GitRepoManager(str(Path(self.dst_directory / self.name)), branch=self.initial_branch)
78+
config = repo.get_config()
79+
config.set(("user", ), "name", "Infrahub Test")
80+
config.set(("user", ), "email", "[email protected]")
81+
config.write_to_path()
7682

77-
files = list(
78-
porcelain.get_untracked_paths(self._repo.git.path, self._repo.git.path, self._repo.git.open_index())
79-
)
83+
self._repo = GitRepoManager(str(dest_path), branch=self.initial_branch)
84+
85+
86+
files = list(porcelain.get_untracked_paths(self._repo.git.path, self._repo.git.path, repo.open_index()))
8087
print(files)
8188
files_to_add = [str(Path(self._repo.git.path) / t) for t in files]
8289
print(files_to_add)
@@ -86,11 +93,23 @@ def init(self) -> None:
8693
porcelain.checkout_branch(self._repo.git, self.initial_branch.encode("utf-8"))
8794

8895
async def add_to_infrahub(self, client: InfrahubClient, branch: str | None = None) -> dict:
96+
repo_path = Path(self.remote_directory_name) / self.name
97+
print(f"Repository path: {repo_path}")
98+
8999
input_data = {
90100
"data": {
91101
"name": {"value": self.name},
92-
"location": {"value": f"{self.remote_directory_name}/{self.name}"},
93-
},
102+
"location": {"value": str(repo_path)},
103+
"git": {
104+
"branch": {"value": self.initial_branch},
105+
"credentials": {
106+
"type": {"value": "none"}
107+
},
108+
"options": {
109+
"bare": {"value": False}
110+
}
111+
}
112+
}
94113
}
95114

96115
query = Mutation(

0 commit comments

Comments
 (0)