feat: implement analyzer and code fixer for identifying and fixing when a sync flag is not propagated correctly.

This commit is contained in:
Stevan Freeborn
2026-06-18 21:28:41 -05:00
parent 86b9673b24
commit f3da2f60fd
45 changed files with 2184 additions and 0 deletions
+67
View File
@@ -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
+19
View File
@@ -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"