@@ -80,14 +80,6 @@ def all_files(path: str, files: List[str]):
8080 files .append (folder )
8181
8282
83- def checkout_azure_default_branch ():
84- usr = 'Azure'
85- branch = 'main'
86- print_exec (f'git remote add { usr } https://github.com/{ usr } /azure-sdk-for-python.git' )
87- print_check (f'git fetch { usr } { branch } ' )
88- print_check (f'git checkout { usr } /{ branch } ' )
89-
90-
9183def modify_file (file_path : str , func : Any ):
9284 with open (file_path , 'r' ) as file_in :
9385 content = file_in .readlines ()
@@ -168,8 +160,27 @@ def get_sdk_folder_with_autorest_result(self):
168160 generate_result = self .get_autorest_result ()
169161 self .sdk_folder = generate_result ["packages" ][0 ]["path" ][0 ].split ('/' )[- 1 ]
170162
163+ @staticmethod
164+ def checkout_branch (env_key : str , repo : str ):
165+ env_var = os .getenv (env_key , "" )
166+ usr = env_var .split (":" )[0 ] or "Azure"
167+ branch = env_var .split (":" )[- 1 ] or "main"
168+ print_exec (f'git remote add { usr } https://github.com/{ usr } /{ repo } .git' )
169+ print_check (f'git fetch { usr } { branch } ' )
170+ print_check (f'git checkout { usr } /{ branch } ' )
171+
172+ @return_origin_path
173+ def checkout_azure_default_branch (self ):
174+ # checkout branch in sdk repo
175+ self .checkout_branch ("DEBUG_SDK_BRANCH" , "azure-sdk-for-python" )
176+
177+ # checkout branch in rest repo
178+ if self .spec_repo :
179+ os .chdir (Path (self .spec_repo ))
180+ self .checkout_branch ("DEBUG_REST_BRANCH" , "azure-rest-api-specs" )
181+
171182 def generate_code (self ):
172- checkout_azure_default_branch ()
183+ self . checkout_azure_default_branch ()
173184
174185 # prepare input data
175186 input_data = {
0 commit comments