Skip to content

Conversation

@Oreoxmt
Copy link
Collaborator

@Oreoxmt Oreoxmt commented Nov 21, 2025

Update the version handling logic to treat the main branch as dev version specifically for TiDB Operator documentation.

@vercel
Copy link

vercel bot commented Nov 21, 2025

@Oreoxmt is attempting to deploy a commit to the pingcap Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • Main Branch Support: The versioning logic has been updated to recognize 'main' as an alias for the development branch, ensuring that both 'master' and 'main' branches correctly map to the 'dev' version.
  • Consistent Version Resolution: This change ensures that repositories using 'main' as their primary branch will have their documentation correctly resolved to the 'dev' version, aligning with modern branching conventions.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Good catch adding main here. I see this branchToVersion function is also present in src/shared/utils/index.ts. Let's keep our codebase DRY and consolidate them. We should export the one from src/shared/utils/index.ts and use it here.

gatsby/utils.ts Outdated
function renameVersion(version: string, stable: string | undefined) {
switch (version) {
case "master":
case "main":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@Oreoxmt Oreoxmt force-pushed the feat/support-operator-main branch from 35d5925 to 05bb57f Compare November 21, 2025 09:33
@Oreoxmt Oreoxmt changed the title feat: return "dev" for Operator main branch feat: treat main branch as dev version for Operator docs Nov 21, 2025
@Oreoxmt
Copy link
Collaborator Author

Oreoxmt commented Nov 21, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +90 to +93
const devBranch = repo === Repo.operator ? "main" : "master";
const stable = CONFIG.docs[repo].stable;
switch (branch) {
case "master":
case devBranch:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic is duplicated in other files. Please see my comment on gatsby/utils.ts for a suggestion to centralize this into a reusable utility function to improve maintainability.

Comment on lines +28 to +39
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");
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Comment on lines +187 to +190
const devBranch = repo === Repo.operator ? "main" : "master";
const stable = CONFIG.docs[repo].stable;
switch (branch) {
case "master":
case devBranch:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic is duplicated in other files. Please see my comment on gatsby/utils.ts for a suggestion to centralize this into a reusable utility function to improve maintainability.

Comment on lines +219 to +221
const devBranch = repo === "tidb-in-kubernetes" ? "main" : "master";
switch (version) {
case "master":
case devBranch:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for determining the dev branch is duplicated here as well. While the default case of this switch is different, the dev branch logic could still be shared. Please see my main comment on gatsby/utils.ts for a refactoring suggestion.

@Oreoxmt
Copy link
Collaborator Author

Oreoxmt commented Nov 21, 2025

Preview environment

Copy link
Member

@shhdgit shhdgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants