@@ -27,20 +27,17 @@ class LocalRepoOperator(RepoOperator):
27
27
28
28
_repo_path : str
29
29
_repo_name : str
30
- _default_branch : str
31
30
_git_cli : GitCLI
32
31
repo_config : BaseRepoConfig
33
32
34
33
def __init__ (
35
34
self ,
36
35
repo_config : BaseRepoConfig ,
37
36
repo_path : str , # full path to the repo
38
- default_branch : str , # default branch of the repo
39
37
bot_commit : bool = True ,
40
38
) -> None :
41
39
self ._repo_path = repo_path
42
40
self ._repo_name = os .path .basename (repo_path )
43
- self ._default_branch = default_branch
44
41
os .makedirs (self .repo_path , exist_ok = True )
45
42
GitCLI .init (self .repo_path )
46
43
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
66
63
create_files (base_dir = repo_path , files = files )
67
64
68
65
# 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 )
70
67
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 )
72
69
return op
73
70
74
71
@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 :
76
73
"""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 )
78
75
if op .get_active_branch_or_commit () != commit :
79
76
op .discard_changes ()
80
77
op .create_remote ("origin" , url )
@@ -104,8 +101,7 @@ def create_from_repo(cls, repo_path: str, url: str) -> Self:
104
101
remote_head = git_cli .remotes .origin .refs [git_cli .active_branch .name ].commit
105
102
# If up to date, use existing repo
106
103
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 )
109
105
except Exception :
110
106
# If any git operations fail, fallback to fresh clone
111
107
pass
@@ -121,9 +117,8 @@ def create_from_repo(cls, repo_path: str, url: str) -> Self:
121
117
122
118
# Initialize with the cloned repo
123
119
git_cli = GitCLI (repo_path )
124
- default_branch = git_cli .active_branch .name
125
120
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 )
127
122
128
123
####################################################################################################################
129
124
# PROPERTIES
0 commit comments