Skip to content

Conversation

@JakeSCahill
Copy link
Contributor

Allows any branch name (not just "dev") to be used as a version, and only applies semantic version parsing when appropriate.

Version normalization and parsing improvements:

  • Updated normalizeTag in tools/bundle-openapi.js to remove special handling for the dev branch and allow any non-semver tag to be treated as a branch name, returning it as-is.
  • Modified getMajorMinor in tools/bundle-openapi.js to only extract major and minor versions if the input is a valid semantic version, otherwise returning the branch name unchanged.

Package metadata update:

  • Bumped the package version in package.json from 4.10.5 to 4.10.6.

@JakeSCahill JakeSCahill requested a review from paulohtb6 October 24, 2025 16:00
@netlify
Copy link

netlify bot commented Oct 24, 2025

Deploy Preview for docs-extensions-and-macros ready!

Name Link
🔨 Latest commit f71326f
🔍 Latest deploy log https://app.netlify.com/projects/docs-extensions-and-macros/deploys/68fba4bb1229f6000826bdfb
😎 Deploy Preview https://deploy-preview-144--docs-extensions-and-macros.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@JakeSCahill JakeSCahill requested a review from kbatuigas October 24, 2025 16:00
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The pull request includes a version bump in package.json from 4.10.5 to 4.10.6. In tools/bundle-openapi.js, the normalizeTag function is modified to return unparseable tags as-is instead of throwing errors, and the special-case handling for the "dev" branch is removed. The getMajorMinor function similarly changes to return non-semver inputs unchanged rather than short-circuiting via an explicit "dev" path, while semver inputs continue to be parsed to major.minor format.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

The diff involves a trivial version bump and straightforward logic modifications to two functions that adjust error handling and branch name processing. The changes are localized to a single utility file, follow a consistent pattern (handling edge cases more gracefully), and introduce no new exported signatures or complex interdependencies.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Enable bundle-openapi CLI to process any branch" directly aligns with the main objective of the changeset. The core purpose of this PR is to modify the bundle-openapi tool to accept any branch name as a version identifier, not just "dev", by updating the normalizeTag and getMajorMinor functions. The title is concise, clear, and accurately summarizes the primary change without vague terminology or unnecessary noise. A developer scanning the commit history would immediately understand that this PR extends the bundle-openapi CLI's branch-handling capabilities.
Description Check ✅ Passed The PR description is directly related to the changeset and provides specific, meaningful details about the changes. It accurately describes the modifications to normalizeTag and getMajorMinor functions that enable handling of any branch name, explains the semantic version parsing behavior, and notes the package version bump from 4.10.5 to 4.10.6. The description is well-organized into logical sections and gives sufficient context about the purpose of each change without being vague or generic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tools/bundle-openapi.js (2)

9-17: Update the docstring to reflect the new behavior.

The function documentation is outdated:

  1. Line 11 mentions "returns 'dev' unchanged" as a special case, but the implementation now returns any non-semver input unchanged (not just 'dev').
  2. Line 17 states "Throws if...does not conform to the expected version format," but the implementation now returns non-semver inputs as-is without throwing.

Apply this diff to update the documentation:

 /**
  * Normalize a Git tag into a semantic version string.
  *
- * Trims surrounding whitespace, returns 'dev' unchanged, removes a leading 'v' if present,
- * and validates that the result matches MAJOR.MINOR.PATCH with optional pre-release/build metadata.
- * Throws if the input is not a non-empty string or does not conform to the expected version format.
+ * Trims surrounding whitespace, removes a leading 'v' if present for semantic versions,
+ * and validates that the result matches MAJOR.MINOR.PATCH with optional pre-release/build metadata.
+ * Non-semantic version strings (e.g., branch names) are returned as-is.
+ * Throws if the input is not a non-empty string.
  *
- * @param {string} tag - Git tag (e.g., 'v25.1.1', '25.1.1', or 'dev').
- * @returns {string} Normalized version (e.g., '25.1.1' or 'dev').
- * @throws {Error} If `tag` is not a non-empty string or does not match the semantic version pattern.
+ * @param {string} tag - Git tag or branch name (e.g., 'v25.1.1', '25.1.1', 'dev', 'enable-branches').
+ * @returns {string} Normalized version for semver inputs (e.g., '25.1.1') or original tag for non-semver inputs (e.g., 'dev').
+ * @throws {Error} If `tag` is not a non-empty string.
  */

42-50: Update the docstring to reflect the new behavior.

The function documentation is outdated. Lines 45-46 state "The special value 'dev' is returned unchanged," but the implementation now returns any non-semver input unchanged, not just 'dev'. The function now treats all non-semver inputs as branch names.

Apply this diff to update the documentation:

 /**
  * Return the major.minor portion of a semantic version string.
  *
- * Accepts a semantic version like `25.1.1` and yields `25.1`. The special value
- * `'dev'` is returned unchanged.
- * @param {string} version - Semantic version (e.g., `'25.1.1'`) or `'dev'`.
- * @returns {string} The `major.minor` string (e.g., `'25.1'`) or `'dev'`.
+ * Accepts a semantic version like `25.1.1` and yields `25.1`. Non-semantic version
+ * inputs (e.g., branch names) are returned unchanged.
+ * @param {string} version - Semantic version (e.g., `'25.1.1'`) or branch name (e.g., `'dev'`, `'enable-branches'`).
+ * @returns {string} The `major.minor` string (e.g., `'25.1'`) for semver inputs, or the original input for non-semver inputs.
  * @throws {Error} If `version` is not a non-empty string, lacks major/minor parts, or if major/minor are not numeric.
  */
🧹 Nitpick comments (1)
tools/bundle-openapi.js (1)

57-57: Consider extracting the duplicate semver pattern.

The semver pattern /^\d+\.\d+\.\d+(-[\w\.-]+)?(\+[\w\.-]+)?$/ is duplicated in both normalizeTag (line 34) and getMajorMinor (line 57). Consider extracting it to a module-level constant to ensure consistency and ease maintenance.

Add at the top of the file (after requires):

const SEMVER_PATTERN = /^\d+\.\d+\.\d+(-[\w\.-]+)?(\+[\w\.-]+)?$/;

Then update both functions:

 function normalizeTag(tag) {
   // ... validation code ...
   const normalized = tag.startsWith('v') ? tag.slice(1) : tag;
-  const semverPattern = /^\d+\.\d+\.\d+(-[\w\.-]+)?(\+[\w\.-]+)?$/;
-  if (semverPattern.test(normalized)) {
+  if (SEMVER_PATTERN.test(normalized)) {
     return normalized;
   }
   return tag;
 }

 function getMajorMinor(version) {
   // ... validation code ...
-  const semverPattern = /^\d+\.\d+\.\d+(-[\w\.-]+)?(\+[\w\.-]+)?$/;
-  if (!semverPattern.test(version)) {
+  if (!SEMVER_PATTERN.test(version)) {
     return version;
   }
   // ... rest of function ...
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c1538cd and c99994d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json (1 hunks)
  • tools/bundle-openapi.js (2 hunks)
🧰 Additional context used
🪛 GitHub Actions: Test Extensions and Macros
package.json

[error] 1-1: Process completed with exit code 1.

tools/bundle-openapi.js

[error] 216-216: OpenAPI bundling encountered a permission denied error while reading a directory during fragment discovery.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules - docs-extensions-and-macros
  • GitHub Check: Header rules - docs-extensions-and-macros
  • GitHub Check: Pages changed - docs-extensions-and-macros
🔇 Additional comments (3)
package.json (1)

3-3: LGTM!

The version bump from 4.10.5 to 4.10.6 is appropriate for this patch release.

tools/bundle-openapi.js (2)

35-39: Verify handling of semver-like branch names.

The current logic treats any input matching the semver pattern (including pre-release suffixes like -dev, -alpha) as a semantic version and strips the v prefix. This means a branch name like v25.1.1-dev-branch would be normalized to 25.1.1-dev-branch and treated as a semver rather than a branch name.

Please confirm this is the intended behavior. If branch names can follow semver-like patterns but should still be treated as branch names, additional logic may be needed to distinguish them.


205-218: No issues found with the debug logging code.

The verification test confirms that the vbuild directory and its contents have standard permissions (drwxr-xr-x for directories, -rw-r--r-- for files) and the recursive directory read completes successfully without permission denied errors. The code at lines 205-218 already includes proper error handling with a try-catch block that logs any errors gracefully.

The pipeline error mentioned in the original review comment appears to be either transient, environment-specific to the CI system, or stemming from a different code section. The logging code itself is functioning as intended.

Copy link

@kbatuigas kbatuigas left a comment

Choose a reason for hiding this comment

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

🚀

@JakeSCahill JakeSCahill merged commit 72f96e4 into main Oct 24, 2025
17 checks passed
@JakeSCahill JakeSCahill deleted the enable-branches branch October 24, 2025 16:19
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.

3 participants