Skip to content
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

Fix getVersionDescription() to prioritize version tags over non-version tags #673

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

OctopBP
Copy link
Contributor

@OctopBP OctopBP commented Oct 3, 2024

Fetching Version Tags:
The command git tag --list --merged HEAD --sort=-creatordate retrieves all tags that have been merged into the current branch, sorted by creation date (newest first).
We then filter these tags to keep only those that match the grepCompatibleInputVersionRegex, which defines valid version tags (like 1.2).

Handling No Version Tags:
If no version tags are found, we fall back to using git describe with --long and --always to provide a generic description.

Using Latest Version Tag:
After filtering the tags, the latest valid tag is used in the git describe command, which ensures we describe the version based on the last suitable tag.

Summary by CodeRabbit

  • New Features

    • Enhanced version description retrieval with improved logic to prioritize valid version tags.
    • Added a warning log for better feedback when no valid version tags are found.
  • Bug Fixes

    • Implemented a fallback mechanism to ensure version information is always available.

…on tags

This fix modifies the getVersionDescription() method to ensure it only considers valid version tags when describing the current version. It retrieves all tags merged into the current branch, filters them based on a version-compatible regex, and uses the most recent valid version tag for description. If no valid tags are found, it falls back to the default description behavior. This resolves the issue of incorrect tags being used when multiple tags are present.
Copy link

coderabbitai bot commented Oct 3, 2024

Warning

Rate limit exceeded

@OctopBP has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between b80318f and b6aaa7c.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes involve a major update to the getVersionDescription method in the Versioning class located in src/model/versioning.ts. The method's logic has been altered to first fetch version tags merged with the current HEAD, applying a regex filter. If no valid tags are found, it defaults to the previous git describe command. Additionally, a warning log has been added for cases where no valid tags are detected, improving the method's feedback mechanism.

Changes

File Path Change Summary
src/model/versioning.ts Updated getVersionDescription method to prioritize fetching valid version tags with regex filtering; added warning log for missing valid tags; fallback to git describe remains.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Versioning
    participant Git

    User->>Versioning: Request version description
    Versioning->>Git: Fetch merged version tags
    alt Valid tags found
        Git-->>Versioning: Return valid tags
        Versioning->>User: Return most recent tag description
    else No valid tags found
        Versioning->>Versioning: Log warning
        Versioning->>Git: Fallback to git describe
        Git-->>Versioning: Return version description
        Versioning->>User: Return version description
    end
Loading

🐇 "In the code where versions play,
Tags now lead the way!
A regex dance, a fallback song,
With warnings clear, we can't go wrong.
Hopping through the logic bright,
Our versioning's a pure delight!" 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Oct 3, 2024

Cat Gif

Rewrote getting the description for the last valid tag using `rev-list` and `rev-parse`
Copy link

@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

🧹 Outside diff range and nitpick comments (3)
src/model/versioning.ts (3)

210-212: Consider removing --merged HEAD for broader tag coverage.

The --merged HEAD option in the git tag command might exclude tags from other branches, potentially limiting the version description. Consider removing this option to include all tags:

-const versionTags = (await this.git(['tag', '--list', '--merged', 'HEAD', '--sort=-creatordate']))
+const versionTags = (await this.git(['tag', '--list', '--sort=-creatordate']))

This change would ensure that all tags are considered, providing a more comprehensive version description.


214-217: Align fallback options with custom implementation.

The fallback mechanism uses different options (--long --tags --always) compared to the custom implementation. Consider aligning these options or explaining the reason for the difference:

-return this.git(['describe', '--long', '--tags', '--always', 'HEAD']);
+return this.git(['describe', '--long', '--always', 'HEAD']);

This change would make the fallback behavior more consistent with the custom implementation, unless there's a specific reason for including --tags in the fallback.


210-222: Approve changes with minor suggestions.

The new implementation of getVersionDescription successfully prioritizes version tags over non-version tags, addressing the main objective of the PR. It provides a more controlled and customized approach to generating version descriptions.

However, consider the following suggestions for improvement:

  1. Add error handling for the git commands to gracefully handle potential failures.
  2. Consider adding a comment explaining the format of the returned version string for better maintainability.

Overall, the changes look good and achieve the desired functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between da6189b and b80318f.

📒 Files selected for processing (1)
  • src/model/versioning.ts (1 hunks)
🔇 Additional comments (1)
src/model/versioning.ts (1)

210-222: Addressing past review comments.

@webbertakken The current implementation addresses your previous concerns:

  1. The --tags option is included in the fallback mechanism (line 216).
  2. The custom implementation uses cross-platform compatible git commands.

The new approach should work in all scenarios on all platforms (Linux, macOS, Windows) with both detached head and normal situations. However, extensive testing across different environments is recommended to ensure full compatibility.

This reverts commit bd58cbe.
This reverts commit bd58cbe.
@OctopBP
Copy link
Contributor Author

OctopBP commented Oct 5, 2024

I also accidentally committed dist files and can't revert them. I don't know if it's ok, if not, please reject it

@GabLeRoux
Copy link
Member

It is fine to commit the dist folder for this project. It is actually expected as per our CONTRIBUTING guide (pull-request-prerequisites).

Before merging PRs, we usually make sure the dist folder hasn’t been tampered with, and I can confirm yours is fine. The reason you were not able to remove it is because we have a hook that handles it.

I reviewed your changes, and they seem fine. I don't have too much context, but that looks good to me.

Thanks for contributing, much appreciated!

@webbertakken webbertakken merged commit b11b6a6 into game-ci:main Oct 7, 2024
2 checks passed
@webbertakken
Copy link
Member

Released in v4.3.0.

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