@@ -40,7 +40,6 @@ def __init__(
4040        if  not  password :
4141            raise  GitOpsException ("Password (Personal Access Token) is required for Azure DevOps" )
4242
43-         # Create connection using Basic Authentication with PAT 
4443        credentials  =  BasicAuthentication (self .__username , password )
4544        self .__connection  =  Connection (base_url = self .__base_url , creds = credentials )
4645        self .__git_client  =  self .__connection .clients .get_git_client ()
@@ -72,7 +71,6 @@ def create_pull_request(
7271        description : str ,
7372    ) ->  GitRepoApi .PullRequestIdAndUrl :
7473        try :
75-             # Ensure branch names have proper refs/ prefix 
7674            source_ref  =  from_branch  if  from_branch .startswith ("refs/" ) else  f"refs/heads/{ from_branch }  
7775            target_ref  =  to_branch  if  to_branch .startswith ("refs/" ) else  f"refs/heads/{ to_branch }  
7876
@@ -110,14 +108,12 @@ def merge_pull_request(
110108        merge_parameters : dict [str , Any ] |  None  =  None ,
111109    ) ->  None :
112110        try :
113-             # Get the pull request to get the last merge source commit 
114111            pr  =  self .__git_client .get_pull_request (
115112                repository_id = self .__repository_name ,
116113                pull_request_id = pr_id ,
117114                project = self .__project_name ,
118115            )
119116
120-             # Map merge methods to Azure DevOps completion options 
121117            completion_options  =  GitPullRequestCompletionOptions ()
122118            if  merge_method  ==  "squash" :
123119                completion_options .merge_strategy  =  "squash" 
@@ -126,12 +122,10 @@ def merge_pull_request(
126122            else :  # merge 
127123                completion_options .merge_strategy  =  "noFastForward" 
128124
129-             # Apply any additional merge parameters 
130125            if  merge_parameters :
131126                for  key , value  in  merge_parameters .items ():
132127                    setattr (completion_options , key , value )
133128
134-             # Update the pull request to complete it 
135129            pr_update  =  GitPullRequest (
136130                status = "completed" ,
137131                last_merge_source_commit = pr .last_merge_source_commit ,
@@ -188,7 +182,6 @@ def _raise_branch_not_found() -> None:
188182            raise  GitOpsException (f"Branch '{ branch }  )
189183
190184        try :
191-             # Get the branch reference first 
192185            refs  =  self .__git_client .get_refs (
193186                repository_id = self .__repository_name ,
194187                project = self .__project_name ,
@@ -214,7 +207,6 @@ def _raise_branch_not_found() -> None:
214207            )
215208
216209        except  GitOpsException :
217-             # Re-raise GitOpsException without modification 
218210            raise 
219211        except  ClientException  as  ex :
220212            error_msg  =  str (ex )
@@ -243,7 +235,6 @@ def _raise_branch_not_found() -> None:
243235            return  str (refs [0 ].object_id )
244236
245237        except  GitOpsException :
246-             # Re-raise GitOpsException without modification 
247238            raise 
248239        except  ClientException  as  ex :
249240            error_msg  =  str (ex )
@@ -263,7 +254,6 @@ def get_pull_request_branch(self, pr_id: int) -> str:
263254                project = self .__project_name ,
264255            )
265256
266-             # Extract branch name from sourceRefName (remove refs/heads/ prefix) 
267257            source_ref  =  str (pr .source_ref_name )
268258            if  source_ref .startswith ("refs/heads/" ):
269259                return  source_ref [11 :]  # Remove "refs/heads/" prefix 
@@ -293,7 +283,6 @@ def __get_default_branch(self) -> str:
293283            )
294284
295285            default_branch  =  repo .default_branch  or  "refs/heads/main" 
296-             # Remove refs/heads/ prefix if present 
297286            if  default_branch .startswith ("refs/heads/" ):
298287                return  default_branch [11 :]
299288            return  default_branch 
0 commit comments