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: use Default .SemVer when git version tag property is not calculable #53

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions apps/semver-yeasy/semver-yeasy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ calculate-version)
GITVERSION_TAG_PROPERTY=${!GITVERSION_TAG_PROPERTY_NAME}

if [ "${GITVERSION_TAG_PROPERTY}" == "" ]; then
GITVERSION_TAG_PROPERTY_NAME="GITVERSION_TAG_PROPERTY_DEFAULT"
GITVERSION_TAG_PROPERTY=${GITVERSION_TAG_PROPERTY_DEFAULT}
fi

service_version=$(echo "${gitversion_calc}" | ${JQ_EXEC_PATH} -r "[${GITVERSION_TAG_PROPERTY}] | join(\"\")")
Comment on lines 96 to 102
Copy link

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [6-6]

The use of tr with square brackets around classes is unnecessary and can be simplified. Also, consider wrapping $2 in double quotes to prevent globbing and word splitting.

- repo_type="$(echo $2 | tr '[[:lower:]]' '[[:upper:]]')"
+ repo_type="$(echo "$2" | tr '[:lower:]' '[:upper:]')"

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [22-22]

Consider wrapping $GITHUB_OUTPUT in double quotes to prevent globbing and word splitting.

- echo "$@" >> $GITHUB_OUTPUT
+ echo "$@" >> "$GITHUB_OUTPUT"

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [66-66]

When assigning arrays from command outputs, prefer using mapfile or read -a to avoid issues with word splitting and to handle non-alphanumeric filenames more robustly.

- changed_services=(`ls -1 apps | xargs -n 1 printf 'apps/%s\n'`)
+ mapfile -t changed_services < <(ls -1 apps | xargs -n 1 printf 'apps/%s\n')

For the git diff command output parsing, consider a similar approach or ensure proper quoting.

Also applies to: 75-75, 77-77


📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [95-95]

In several places, the script uses tr with unnecessary square brackets around classes. Simplify these expressions by removing the square brackets.

- GITVERSION_TAG_PROPERTY_NAME="GITVERSION_TAG_PROPERTY_$(echo "${DIFF_SOURCE}" | sed 's|/.*$||' | tr '[[:lower:]]' '[[:upper:]]')"
+ GITVERSION_TAG_PROPERTY_NAME="GITVERSION_TAG_PROPERTY_$(echo "${DIFF_SOURCE}" | sed 's|/.*$||' | tr '[:lower:]' '[:upper:]')"

Also applies to: 128-128, 182-182, 209-209

Expand Down Expand Up @@ -124,10 +124,11 @@ calculate-version)
log "gitversion_calc=$($gitversion_calc_cmd 2>&1)"
exit_status=$?
log "Exit status: $exit_status" >> $GITHUB_OUTPUT

GITVERSION_TAG_PROPERTY_NAME="GITVERSION_TAG_PROPERTY_$(echo "${DIFF_SOURCE}" | sed 's|/.*$||' | tr '[[:lower:]]' '[[:upper:]]')"

if [ "${GITVERSION_TAG_PROPERTY}" == "" ]; then
GITVERSION_TAG_PROPERTY_NAME="GITVERSION_TAG_PROPERTY_DEFAULT"
GITVERSION_TAG_PROPERTY=${GITVERSION_TAG_PROPERTY_DEFAULT}
fi

GITVERSION_TAG_PROPERTY=${!GITVERSION_TAG_PROPERTY_NAME}
Expand Down Expand Up @@ -182,7 +183,7 @@ tag)
GITVERSION_TAG_PROPERTY=${!GITVERSION_TAG_PROPERTY_NAME}

if [ "${GITVERSION_TAG_PROPERTY}" == "" ]; then
GITVERSION_TAG_PROPERTY_NAME="GITVERSION_TAG_PROPERTY_DEFAULT"
GITVERSION_TAG_PROPERTY=${GITVERSION_TAG_PROPERTY_DEFAULT}
fi

service_version=$(echo "${gitversion_calc}" | ${JQ_EXEC_PATH} -r "[${GITVERSION_TAG_PROPERTY}] | join(\"\")")
Expand All @@ -209,7 +210,7 @@ tag)
GITVERSION_TAG_PROPERTY=${!GITVERSION_TAG_PROPERTY_NAME}

if [ "${GITVERSION_TAG_PROPERTY}" == "" ]; then
GITVERSION_TAG_PROPERTY_NAME="GITVERSION_TAG_PROPERTY_DEFAULT"
GITVERSION_TAG_PROPERTY=${GITVERSION_TAG_PROPERTY_DEFAULT}
fi

service_version=$(echo "${gitversion_calc}" | ${JQ_EXEC_PATH} -r "[${GITVERSION_TAG_PROPERTY}] | join(\"\")")
Expand Down