Skip to content

Commit 6950b3c

Browse files
authored
Merge pull request #1658 from qodo-ai/es/bugfix_on_help_docs_no_references_when_new_issue_created
Fix for bug in get_canonical_url_parts when a new issue created, without git url provided
2 parents 66a667d + e422f50 commit 6950b3c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pr_agent/git_providers/github_provider.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)