Skip to content

Commit 84ddea3

Browse files
committed
jbr-debug-access-right-test
1 parent 1e3db93 commit 84ddea3

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ jobs:
190190
uses: actions/setup-python@v5
191191
with:
192192
python-version: "3.12"
193+
- name: "Setup git credentials"
194+
run: "git config --global user.name 'Infrahub' && \
195+
git config --global user.email '[email protected]' && \
196+
git config --global --add safe.directory '*' && \
197+
git config --global credential.usehttppath true && \
198+
git config --global credential.helper /usr/local/bin/infrahub-git-credential"
193199
- name: "Setup environment"
194200
run: |
195201
pipx install poetry==1.8.5

infrahub_sdk/testing/repository.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import asyncio
44
import shutil
5-
import os
65
from dataclasses import dataclass, field
76
from enum import Enum
87
from 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

Comments
 (0)