Skip to content

Commit 213979f

Browse files
chore(CG-10447): add github_type param for remote repo operator (#58)
1 parent b468295 commit 213979f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/codegen/git/repo_operator/remote_repo_operator.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class RemoteRepoOperator(RepoOperator):
2727
# __init__ attributes
2828
repo_config: RepoConfig
2929
base_dir: str
30+
github_type: GithubType
3031

3132
# lazy attributes
3233
_remote_git_repo: GitRepoClient | None = None
@@ -43,6 +44,7 @@ def __init__(
4344
github_type: GithubType = GithubType.GithubEnterprise,
4445
) -> None:
4546
super().__init__(repo_config=repo_config, base_dir=base_dir)
47+
self.github_type = github_type
4648
self.setup_repo_dir(setup_option=setup_option, shallow=shallow)
4749

4850
####################################################################################################################
@@ -52,7 +54,7 @@ def __init__(
5254
@property
5355
def remote_git_repo(self) -> GitRepoClient:
5456
if not self._remote_git_repo:
55-
self._remote_git_repo = GitRepoClient(self.repo_config, access_scope=GithubScope.WRITE)
57+
self._remote_git_repo = GitRepoClient(self.repo_config, github_type=self.github_type, access_scope=GithubScope.WRITE)
5658
return self._remote_git_repo
5759

5860
@property
@@ -74,17 +76,17 @@ def codeowners_parser(self) -> CodeOwnersParser | None:
7476
@override
7577
def pull_repo(self) -> None:
7678
"""Pull the latest commit down to an existing local repo"""
77-
pull_repo(repo=self.repo_config, path=self.base_dir)
79+
pull_repo(repo=self.repo_config, path=self.base_dir, github_type=self.github_type)
7880

7981
def clone_repo(self, shallow: bool = True) -> None:
80-
clone_repo(repo=self.repo_config, path=self.base_dir, shallow=shallow)
82+
clone_repo(repo=self.repo_config, path=self.base_dir, shallow=shallow, github_type=self.github_type)
8183

8284
def clone_or_pull_repo(self, shallow: bool = True) -> None:
8385
"""If repo exists, pulls changes. otherwise, clones the repo."""
8486
# TODO(CG-7804): if repo is not valid we should delete it and re-clone. maybe we can create a pull_repo util + use the existing clone_repo util
8587
if self.repo_exists():
8688
self.clean_repo()
87-
clone_or_pull_repo(self.repo_config, path=self.base_dir, shallow=shallow)
89+
clone_or_pull_repo(self.repo_config, path=self.base_dir, shallow=shallow, github_type=self.github_type)
8890

8991
def setup_repo_dir(self, setup_option: SetupOption = SetupOption.PULL_OR_CLONE, shallow: bool = True) -> None:
9092
os.makedirs(self.base_dir, exist_ok=True)

0 commit comments

Comments
 (0)