-
Notifications
You must be signed in to change notification settings - Fork 34
feat: treat main branch as dev version for Operator docs
#651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@Oreoxmt is attempting to deploy a commit to the pingcap Team on Vercel. A member of the Team first needs to authorize it. |
Summary of ChangesHello @Oreoxmt, 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 introduces support for the 'main' branch in the versioning system. It modifies several utility functions to treat 'main' identically to 'master' when determining the 'dev' version of a repository's documentation. This update is crucial for maintaining compatibility and correct version resolution for projects that have transitioned from 'master' to 'main' as their default branch. 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 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 counter productive. 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR correctly adds support for the main branch to be treated as dev. The changes are consistent across the codebase. I've added a couple of comments pointing out opportunities to refactor some duplicated utility functions. Addressing this will improve code maintainability. Nice work!
gatsby/path.ts
Outdated
| const stable = CONFIG.docs[repo].stable; | ||
| switch (branch) { | ||
| case "master": | ||
| case "main": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gatsby/utils.ts
Outdated
| function renameVersion(version: string, stable: string | undefined) { | ||
| switch (version) { | ||
| case "master": | ||
| case "main": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this. This renameVersion function is almost a mirror of convertVersionName in src/shared/utils/index.ts. To avoid future maintenance headaches, let's merge them. The version in shared/utils should probably be updated to handle an undefined stable version, and then we can use it here.
35d5925 to
05bb57f
Compare
main branch as dev version for Operator docs
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the version handling logic to treat the main branch as the dev version for TiDB Operator documentation. The changes are applied correctly across several files. However, this introduces significant code duplication for the branch-to-version conversion logic. My review includes suggestions to refactor this into a centralized utility function to improve maintainability.
| const devBranch = repo === Repo.operator ? "main" : "master"; | ||
| const stable = CONFIG.docs[repo].stable; | ||
| switch (branch) { | ||
| case "master": | ||
| case devBranch: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| case "tidb-in-kubernetes": { | ||
| const devBranch = doc === "tidb-in-kubernetes" ? "main" : "master"; | ||
| const stable = getStable(doc); | ||
| switch (version) { | ||
| case devBranch: | ||
| return "dev"; | ||
| case stable: | ||
| return "stable"; | ||
| default: | ||
| return version.replace("release-", "v"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this change is functionally correct, the logic for determining the dev branch and converting it to a version name is now duplicated in at least three places (gatsby/path.ts, gatsby/utils.ts, and src/shared/utils/index.ts).
To improve maintainability and follow the DRY (Don't Repeat Yourself) principle, I recommend extracting this logic into a single, reusable utility function. You could re-introduce a function similar to the renameVersion that was removed, but make it more generic and export it so it can be used across the codebase.
For example:
// Could be placed in a shared utils file
export function getVersionFromBranch(branch: string, repo: Repo, stable: string | undefined) {
const devBranch = repo === 'tidb-in-kubernetes' ? 'main' : 'master';
switch (branch) {
case devBranch:
return 'dev';
case stable:
return 'stable';
default:
return branch.replace('release-', 'v');
}
}Using this helper would simplify the code in all affected locations.
| const devBranch = repo === Repo.operator ? "main" : "master"; | ||
| const stable = CONFIG.docs[repo].stable; | ||
| switch (branch) { | ||
| case "master": | ||
| case devBranch: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const devBranch = repo === "tidb-in-kubernetes" ? "main" : "master"; | ||
| switch (version) { | ||
| case "master": | ||
| case devBranch: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Preview environment
|
shhdgit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
Update the version handling logic to treat the
mainbranch asdevversion specifically for TiDB Operator documentation.