feat: implement analyzer and code fixer for identifying and fixing when a sync flag is not propagated correctly.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
branch="${1:-main}"
|
||||
|
||||
tag=$(git describe --tags --abbrev=0 2>/dev/null)
|
||||
base="${tag:-$branch}"
|
||||
|
||||
commits=$(git log "$base..HEAD" --format="%s")
|
||||
major=0
|
||||
minor=0
|
||||
patch=0
|
||||
|
||||
while IFS= read -r message; do
|
||||
if [[ -n "$message" ]] && [[ "$message" =~ " BREAKING CHANGE|!:" ]]; then
|
||||
major=1
|
||||
elif [[ -n "$message" ]] && [[ "$message" =~ feat(\(.*\))?: ]]; then
|
||||
minor=1
|
||||
elif [[ -n "$message" ]] && [[ "$message" =~ fix(\(.*\))?: ]]; then
|
||||
patch=1
|
||||
fi
|
||||
done <<< "$commits"
|
||||
|
||||
if [[ "$major" -eq 1 ]]; then
|
||||
minor=0
|
||||
patch=0
|
||||
elif [[ "$minor" -eq 1 ]]; then
|
||||
patch=0
|
||||
elif [[ "$patch" -eq 0 ]] && [[ -n "$commits" ]]; then
|
||||
patch=1
|
||||
fi
|
||||
|
||||
currentVersion="0.0.0"
|
||||
hasExistingTag=false
|
||||
|
||||
if [[ -n "$tag" ]]; then
|
||||
hasExistingTag=true
|
||||
currentVersion="${tag#v}"
|
||||
fi
|
||||
|
||||
IFS='.' read -r majorCurrent minorCurrent patchCurrent <<< "$currentVersion"
|
||||
|
||||
majorNew=$((majorCurrent + major))
|
||||
|
||||
if [[ "$major" -eq 1 ]]; then
|
||||
minorNew=0
|
||||
else
|
||||
minorNew=$((minorCurrent + minor))
|
||||
fi
|
||||
|
||||
if [[ "$major" -eq 1 ]] || [[ "$minor" -eq 1 ]]; then
|
||||
patchNew=0
|
||||
else
|
||||
patchNew=$((patchCurrent + patch))
|
||||
fi
|
||||
|
||||
if [[ "$majorNew" -eq "$majorCurrent" ]] && [[ "$minorNew" -eq "$minorCurrent" ]] && [[ "$patchNew" -eq "$patchCurrent" ]]; then
|
||||
if [[ "$hasExistingTag" == "false" ]]; then
|
||||
version="0.0.0"
|
||||
[[ -n "$GITHUB_OUTPUT" ]] && echo "VERSION=$version" >> "$GITHUB_OUTPUT" || echo "VERSION=$version"
|
||||
echo "First release: publishing version 0.0.0"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
version="$majorNew.$minorNew.$patchNew"
|
||||
[[ -n "$GITHUB_OUTPUT" ]] && echo "VERSION=$version" >> "$GITHUB_OUTPUT" || echo "VERSION=$version"
|
||||
fi
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
version="${1:-}"
|
||||
csprojPath="${2:-src/StevanFreeborn.AsyncSyncFlagAnalyzer/StevanFreeborn.AsyncSyncFlagAnalyzer.csproj}"
|
||||
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "Error: Version is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
content=$(cat "$csprojPath")
|
||||
|
||||
if [[ "$content" =~ \<Version\>.*?\</Version\> ]]; then
|
||||
content=$(echo "$content" | sed "s|<Version>.*</Version>|<Version>$version</Version>|")
|
||||
elif [[ "$content" =~ \<PropertyGroup\> ]]; then
|
||||
content=$(echo "$content" | sed "s|<PropertyGroup>|<PropertyGroup>\\n <Version>$version</Version>|")
|
||||
fi
|
||||
|
||||
echo "$content" > "$csprojPath"
|
||||
Reference in New Issue
Block a user