-
Notifications
You must be signed in to change notification settings - Fork 35
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,23 +21,22 @@ export function getStable(doc: Repo) { | |
| return undefined; | ||
| } | ||
|
|
||
| function renameVersion(version: string, stable: string | undefined) { | ||
| switch (version) { | ||
| case "master": | ||
| return "dev"; | ||
| case stable: | ||
| return "stable"; | ||
| default: | ||
| return version.replace("release-", "v"); | ||
| } | ||
| } | ||
|
|
||
| export function renameVersionByDoc(doc: Repo, version: string) { | ||
| switch (doc) { | ||
| case "tidb": | ||
| case "tidb-data-migration": | ||
| case "tidb-in-kubernetes": | ||
| return renameVersion(version, getStable(doc)); | ||
| 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"); | ||
| } | ||
| } | ||
|
Comment on lines
+28
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this change is functionally correct, the logic for determining the 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 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. |
||
| case "tidbcloud": | ||
| return; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,9 +184,10 @@ function branchToVersion(repo: Repo, branch: string) { | |
| switch (repo) { | ||
| case Repo.tidb: | ||
| case Repo.operator: { | ||
| const devBranch = repo === Repo.operator ? "main" : "master"; | ||
| const stable = CONFIG.docs[repo].stable; | ||
| switch (branch) { | ||
| case "master": | ||
| case devBranch: | ||
|
Comment on lines
+187
to
+190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return "dev"; | ||
| case stable: | ||
| return "stable"; | ||
|
|
@@ -214,9 +215,10 @@ export const AllVersion = Object.keys(CONFIG.docs).reduce((acc, val) => { | |
| return acc; | ||
| }, {} as Record<Repo, Record<Locale, (string | null)[]>>); | ||
|
|
||
| export function convertVersionName(version: string, stable: string) { | ||
| export function convertVersionName(version: string, stable: string, repo?: string) { | ||
| const devBranch = repo === "tidb-in-kubernetes" ? "main" : "master"; | ||
| switch (version) { | ||
| case "master": | ||
| case devBranch: | ||
|
Comment on lines
+219
to
+221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return "dev"; | ||
| case stable: | ||
| return "stable"; | ||
|
|
||
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.
This logic is duplicated in other files. Please see my comment on
gatsby/utils.tsfor a suggestion to centralize this into a reusable utility function to improve maintainability.