@@ -118,16 +118,19 @@ def get_canonical_url_parts(self, repo_git_url:str, desired_branch:str) -> Tuple
118118 repo = None
119119 scheme_and_netloc = None
120120
121- if repo_git_url : #If user provided an external git url, which may be different than what this provider was initialized with, we cannot use self.repo
122- repo_path = self ._get_owner_and_repo_path (repo_git_url )
123- parsed_git_url = urlparse (repo_git_url )
121+ if repo_git_url or self .issue_main : #Either user provided an external git url, which may be different than what this provider was initialized with, or an issue:
122+ desired_branch = desired_branch if repo_git_url else self .issue_main .repository .default_branch
123+ html_url = repo_git_url if repo_git_url else self .issue_main .html_url
124+ parsed_git_url = urlparse (html_url )
124125 scheme_and_netloc = parsed_git_url .scheme + "://" + parsed_git_url .netloc
126+ repo_path = self ._get_owner_and_repo_path (html_url )
125127 if repo_path .count ('/' ) == 1 : #Has to have the form <owner>/<repo>
126128 owner , repo = repo_path .split ('/' )
127129 else :
128- get_logger ().error (f"Invalid repo_path: { repo_path } from repo_git_url : { repo_git_url } " )
130+ get_logger ().error (f"Invalid repo_path: { repo_path } from url : { html_url } " )
129131 return ("" , "" )
130- if (not owner or not repo ) and self .repo : #"else" - User did not provide an external git url, use self.repo object:
132+
133+ if (not owner or not repo ) and self .repo : #"else" - User did not provide an external git url, or not an issue, use self.repo object
131134 owner , repo = self .repo .split ('/' )
132135 scheme_and_netloc = self .base_url_html
133136 desired_branch = self .get_pr_branch ()
0 commit comments