2424class RemoteRepoOperator (RepoOperator ):
2525 """A wrapper around GitPython to make it easier to interact with a cloned lowside repo."""
2626
27+ # __init__ attributes
2728 repo_config : RepoConfig
2829 base_dir : str
30+
31+ # lazy attributes
2932 _remote_git_repo : GitRepoClient | None = None
3033 _codeowners_parser : CodeOwnersParser | None = None
3134 _default_branch : str | None = None
32- bot_commit : bool = True
3335
3436 # TODO: allow setting the access scope level of the lowside repo (currently it's always WRITE)
3537 def __init__ (
@@ -38,9 +40,9 @@ def __init__(
3840 base_dir : str = "/tmp" ,
3941 setup_option : SetupOption = SetupOption .PULL_OR_CLONE ,
4042 shallow : bool = True ,
41- bot_commit : bool = True ,
43+ github_type : GithubType = GithubType . GithubEnterprise ,
4244 ) -> None :
43- super ().__init__ (repo_config = repo_config , base_dir = base_dir , bot_commit = bot_commit )
45+ super ().__init__ (repo_config = repo_config , base_dir = base_dir )
4446 self .setup_repo_dir (setup_option = setup_option , shallow = shallow )
4547
4648 ####################################################################################################################
@@ -50,8 +52,7 @@ def __init__(
5052 @property
5153 def remote_git_repo (self ) -> GitRepoClient :
5254 if not self ._remote_git_repo :
53- # NOTE: local repo operator by default points at lowside (i.e. origin remote is lowside remote)
54- self ._remote_git_repo = GitRepoClient (self .repo_config , github_type = GithubType .GithubEnterprise , access_scope = GithubScope .WRITE )
55+ self ._remote_git_repo = GitRepoClient (self .repo_config , access_scope = GithubScope .WRITE )
5556 return self ._remote_git_repo
5657
5758 @property
@@ -69,27 +70,31 @@ def codeowners_parser(self) -> CodeOwnersParser | None:
6970 ####################################################################################################################
7071 # SET UP
7172 ####################################################################################################################
73+
7274 @override
7375 def pull_repo (self ) -> None :
7476 """Pull the latest commit down to an existing local repo"""
7577 pull_repo (repo = self .repo_config , path = self .base_dir )
7678
77- def clone_or_pull_repo (self ) -> None :
79+ def clone_repo (self , shallow : bool = True ) -> None :
80+ clone_repo (repo = self .repo_config , path = self .base_dir , shallow = shallow )
81+
82+ def clone_or_pull_repo (self , shallow : bool = True ) -> None :
7883 """If repo exists, pulls changes. otherwise, clones the repo."""
7984 # 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
8085 if self .repo_exists ():
8186 self .clean_repo ()
82- clone_or_pull_repo (self .repo_config , path = self .base_dir , shallow = True )
87+ clone_or_pull_repo (self .repo_config , path = self .base_dir , shallow = shallow )
8388
8489 def setup_repo_dir (self , setup_option : SetupOption = SetupOption .PULL_OR_CLONE , shallow : bool = True ) -> None :
8590 os .makedirs (self .base_dir , exist_ok = True )
8691 os .chdir (self .base_dir )
8792 if setup_option is SetupOption .CLONE :
8893 # if repo exists delete, then clone, else clone
89- clone_repo (repo = self . repo_config , path = self . base_dir , shallow = shallow )
94+ clone_repo (shallow = shallow )
9095 elif setup_option is SetupOption .PULL_OR_CLONE :
9196 # if repo exists, pull changes, else clone
92- self .clone_or_pull_repo ()
97+ self .clone_or_pull_repo (shallow = shallow )
9398 elif setup_option is SetupOption .SKIP :
9499 if not self .repo_exists ():
95100 logger .warning (f"Valid git repo does not exist at { self .repo_path } . Cannot skip setup with SetupOption.SKIP." )
0 commit comments