fix(extensions): strip only a trailing .git suffix when parsing GitHub repo names - #29097
fix(extensions): strip only a trailing .git suffix when parsing GitHub repo names#29097Eswar809 wants to merge 1 commit into
Conversation
…b repo names (google-gemini#29037) String.prototype.replace('.git', '') removed the first occurrence of '.git' anywhere in the repo name, mangling repos like blog.github.io into hub.io and breaking release-based install/update. Anchor the strip to the end of the name instead.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a bug in the GitHub URL parsing logic where the code incorrectly stripped the first occurrence of '.git' from repository names, regardless of its position. By anchoring the replacement to the end of the string, the fix ensures that valid repository names containing '.git' (such as those for GitHub Pages sites) are parsed correctly, preventing API errors and state corruption. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request fixes an issue in the GitHub URL parser where any occurrence of ".git" in the repository name was incorrectly stripped. The code has been updated to only strip a trailing ".git" suffix case-insensitively using a regular expression. Corresponding unit tests have been added to verify this behavior. There are no review comments, and I have no feedback to provide.
TLDR
tryParseGithubUrlusedString.prototype.replace('.git', ''), which strips the first occurrence of.gitanywhere in the repo name — not just a trailing suffix. Repos likeblog.github.iowere parsed ashub.io, producing wrong API URLs (/repos/owner/hub.io/releases/latest→ 404) and corrupting the extension id used for dedup in settings/state.This anchors the strip to the end of the name:
.replace(/\.git$/i, '').Testing
https://github.com/owner/blog.github.io→blog.github.io(previously mangled tohub.io)https://github.com/owner/my.git.repo.git→my.git.repohttps://github.com/owner/repo.GIT→repo(case-insensitive suffix)owner/repoforms of the abovegithub.test.tsChecklist