-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add VERSION file update with gitversion semver on checkout #11
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: main
Are you sure you want to change the base?
Conversation
Co-authored-by: tomgrv <[email protected]>
Co-authored-by: tomgrv <[email protected]>
Co-authored-by: tomgrv <[email protected]>
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.
@copilot update package version
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.
Pull Request Overview
This PR implements automatic VERSION file updates using GitVersion semver on checkout to provide developers with visibility into their current working version.
- Added a VERSION file that gets automatically updated with semver information
- Created an intelligent version update script that tries GitVersion first, then falls back to git describe
- Enhanced the post-checkout hook to automatically update the VERSION file on branch/commit switches
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
update-version.sh | New script that determines current version using GitVersion or git describe fallback |
src/githooks/_post-checkout.sh | Enhanced to call the version update script automatically |
VERSION | New file containing the current version string |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -0,0 +1,54 @@ | |||
#!/bin/bash |
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.
The script is missing the executable permission setting. Consider adding a comment about setting executable permissions or ensuring the file is created with proper permissions.
#!/bin/bash | |
#!/bin/bash | |
# Ensure this script is executable: chmod +x update-version.sh |
Copilot uses AI. Check for mistakes.
# Extract version from patterns like: | ||
# feature_larasets_5.10.2-1-g97bdb34 -> 5.10.2-1-g97bdb34 | ||
# feature_larasets_5.10.2 -> 5.10.2 | ||
echo "$describe_output" | sed -E 's/^[^_]*_[^_]*_([0-9]+\.[0-9]+\.[0-9]+.*)/\1/' | head -1 |
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.
The regex pattern is complex and assumes a specific tag naming convention (feature_larasets_X.Y.Z). Consider adding a comment explaining the expected tag format or making the pattern more flexible to handle different tag naming conventions.
# Extract version from patterns like: | |
# feature_larasets_5.10.2-1-g97bdb34 -> 5.10.2-1-g97bdb34 | |
# feature_larasets_5.10.2 -> 5.10.2 | |
echo "$describe_output" | sed -E 's/^[^_]*_[^_]*_([0-9]+\.[0-9]+\.[0-9]+.*)/\1/' | head -1 | |
# Extract version from tags ending with a semantic version, e.g.: | |
# feature_larasets_5.10.2-1-g97bdb34 -> 5.10.2-1-g97bdb34 | |
# release_5.10.2 -> 5.10.2 | |
# v5.10.2 -> 5.10.2 | |
# The regex matches any tag ending with X.Y.Z (optionally with suffixes). | |
echo "$describe_output" | sed -E 's/.*[_v]([0-9]+\.[0-9]+\.[0-9]+([-a-zA-Z0-9\.]*)?)/\1/' | head -1 |
Copilot uses AI. Check for mistakes.
# Try to get MajorMinorPatch from GitVersion | ||
GITVERSION_OUTPUT=$(dotnet-gitversion -config .gitversion -showvariable MajorMinorPatch 2>/dev/null || echo "") | ||
# Check if output is a valid version number (only digits and dots) and not default | ||
if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$' && [ "$GITVERSION_OUTPUT" != "1.0.0" ]; then |
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.
The hardcoded exclusion of '1.0.0' as a default value may not be reliable if a project legitimately has version 1.0.0. Consider checking for GitVersion's actual error conditions or configuration instead of excluding specific version numbers.
if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$' && [ "$GITVERSION_OUTPUT" != "1.0.0" ]; then | |
if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then |
Copilot uses AI. Check for mistakes.
This PR implements automatic VERSION file updates with GitVersion semver on each checkout, allowing developers to easily see what version they're currently working on.
Changes Made
1. Created VERSION File
VERSION
file in the repository root that gets automatically updated1.0.0
and managed by the version update system2. Version Update Script
Created
update-version.sh
that intelligently determines the current version:The script handles various scenarios:
feature_larasets_5.10.2
→5.10.2-2-g51926a7
3. Enhanced Post-Checkout Hook
Modified
src/githooks/_post-checkout.sh
to automatically call the version update script:How It Works
cat VERSION
to see their current working versionExample Usage
This integrates seamlessly with the existing GitVersion configuration and devcontainer features workflow, requiring no manual intervention once the githooks feature is installed and configured.
Fixes #10.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.