@@ -27,20 +27,17 @@ class LocalRepoOperator(RepoOperator):
2727
2828 _repo_path : str
2929 _repo_name : str
30- _default_branch : str
3130 _git_cli : GitCLI
3231 repo_config : BaseRepoConfig
3332
3433 def __init__ (
3534 self ,
3635 repo_config : BaseRepoConfig ,
3736 repo_path : str , # full path to the repo
38- default_branch : str , # default branch of the repo
3937 bot_commit : bool = True ,
4038 ) -> None :
4139 self ._repo_path = repo_path
4240 self ._repo_name = os .path .basename (repo_path )
43- self ._default_branch = default_branch
4441 os .makedirs (self .repo_path , exist_ok = True )
4542 GitCLI .init (self .repo_path )
4643 super ().__init__ (repo_config , self .repo_path , bot_commit )
@@ -66,15 +63,15 @@ def create_from_files(cls, repo_path: str, files: dict[str, str], bot_commit: bo
6663 create_files (base_dir = repo_path , files = files )
6764
6865 # Step 2: Init git repo
69- op = cls (repo_path = repo_path , default_branch = "main" , bot_commit = bot_commit , repo_config = repo_config )
66+ op = cls (repo_path = repo_path , bot_commit = bot_commit , repo_config = repo_config )
7067 if op .stage_and_commit_all_changes ("[Codegen] initial commit" ):
71- op .checkout_branch (op . default_branch , create_if_missing = True )
68+ op .checkout_branch (None , create_if_missing = True )
7269 return op
7370
7471 @classmethod
75- def create_from_commit (cls , repo_path : str , default_branch : str , commit : str , url : str ) -> Self :
72+ def create_from_commit (cls , repo_path : str , commit : str , url : str ) -> Self :
7673 """Do a shallow checkout of a particular commit to get a repository from a given remote URL."""
77- op = cls (repo_config = BaseRepoConfig (), repo_path = repo_path , default_branch = default_branch , bot_commit = False )
74+ op = cls (repo_config = BaseRepoConfig (), repo_path = repo_path , bot_commit = False )
7875 if op .get_active_branch_or_commit () != commit :
7976 op .discard_changes ()
8077 op .create_remote ("origin" , url )
@@ -104,8 +101,7 @@ def create_from_repo(cls, repo_path: str, url: str) -> Self:
104101 remote_head = git_cli .remotes .origin .refs [git_cli .active_branch .name ].commit
105102 # If up to date, use existing repo
106103 if local_head .hexsha == remote_head .hexsha :
107- default_branch = git_cli .active_branch .name
108- return cls (repo_config = BaseRepoConfig (), repo_path = repo_path , default_branch = default_branch , bot_commit = False )
104+ return cls (repo_config = BaseRepoConfig (), repo_path = repo_path , bot_commit = False )
109105 except Exception :
110106 # If any git operations fail, fallback to fresh clone
111107 pass
@@ -121,9 +117,8 @@ def create_from_repo(cls, repo_path: str, url: str) -> Self:
121117
122118 # Initialize with the cloned repo
123119 git_cli = GitCLI (repo_path )
124- default_branch = git_cli .active_branch .name
125120
126- return cls (repo_config = BaseRepoConfig (), repo_path = repo_path , default_branch = default_branch , bot_commit = False )
121+ return cls (repo_config = BaseRepoConfig (), repo_path = repo_path , bot_commit = False )
127122
128123 ####################################################################################################################
129124 # PROPERTIES
0 commit comments