You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/03/03 14:02:55 UTC

[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6605: Fix the "PR-to-Update-Go" GitHub Action

zrhoffman commented on a change in pull request #6605:
URL: https://github.com/apache/trafficcontrol/pull/6605#discussion_r818226004



##########
File path: .github/actions/pr-to-update-go/pr_to_update_go/go_pr_maker.py
##########
@@ -247,22 +314,22 @@ def get_repo(self, repo_name: str) -> Repository:
 			raise PermissionError(f"Credentials from token '{ENV_GITHUB_TOKEN}' were bad") from e
 		return repo
 
-	def get_go_milestone(self, go_version: str) -> Optional[str]:
+	def get_go_milestone(self, go_version: str) -> str:
 		"""
 		Gets a URL for the GitHub milestone that tracks the release of the
 		passed Go version.
 
 		If the passed version is not found to have a milestone associated with
-		it, an exception is raised.
+		it, a LookupError exception is raised.
 		"""
-		go_repo: Repository = self.get_repo(GO_REPO_NAME)
+		go_repo = self.get_repo(GO_REPO_NAME)
 		milestones = go_repo.get_milestones(state='all', sort='due_on', direction='desc')
 		milestone_title = f'Go{go_version}'
 		for milestone in milestones:  # type: Milestone
 			if milestone.title == milestone_title:
 				print(f'Found Go milestone {milestone.title}')
-				return milestone.raw_data.get('html_url')
-		raise Exception(f'Could not find a milestone named {milestone_title}.')
+				return milestone.url

Review comment:
       `url` is the API URL like https://api.github.com/repos/golang/go/milestones/243 , it needs to be the HTML URL like https://github.com/golang/go/milestone/243

##########
File path: .github/actions/pr-to-update-go/pr_to_update_go/go_pr_maker.py
##########
@@ -247,22 +314,22 @@ def get_repo(self, repo_name: str) -> Repository:
 			raise PermissionError(f"Credentials from token '{ENV_GITHUB_TOKEN}' were bad") from e
 		return repo
 
-	def get_go_milestone(self, go_version: str) -> Optional[str]:
+	def get_go_milestone(self, go_version: str) -> str:
 		"""
 		Gets a URL for the GitHub milestone that tracks the release of the
 		passed Go version.
 
 		If the passed version is not found to have a milestone associated with
-		it, an exception is raised.
+		it, a LookupError exception is raised.
 		"""
-		go_repo: Repository = self.get_repo(GO_REPO_NAME)
+		go_repo = self.get_repo(GO_REPO_NAME)
 		milestones = go_repo.get_milestones(state='all', sort='due_on', direction='desc')
 		milestone_title = f'Go{go_version}'
 		for milestone in milestones:  # type: Milestone

Review comment:
       Nit: There is no import for the `Milestone` type. It looks like the type comment can just be removed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org