Skip to content

Commit cfc32d4

Browse files
Merge pull request #107 from ExtremeFiretop/ExtremeFiretop-ChangeLog-Review
Update MerlinAU.sh Updated the Changelog Review Logic
2 parents 7980ce7 + 5af32b8 commit cfc32d4

File tree

1 file changed

+41
-26
lines changed

1 file changed

+41
-26
lines changed

MerlinAU.sh

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
#
55
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7-
# Last Modified: 2024-Jan-29
7+
# Last Modified: 2024-Jan-30
88
###################################################################
99
set -u
1010

1111
#For AMTM versioning:
12-
readonly SCRIPT_VERSION=1.0.0
12+
readonly SCRIPT_VERSION=1.0.1
1313
readonly SCRIPT_NAME="MerlinAU"
1414

1515
##-------------------------------------##
@@ -2568,7 +2568,7 @@ Please manually update to version $minimum_supported_version or higher to use th
25682568
cd "$FW_BIN_DIR"
25692569

25702570
##------------------------------------------##
2571-
## Modified by ExtremeFiretop [2024-Jan-25] ##
2571+
## Modified by ExtremeFiretop [2024-Jan-30] ##
25722572
##------------------------------------------##
25732573
local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")"
25742574

@@ -2583,36 +2583,51 @@ Please manually update to version $minimum_supported_version or higher to use th
25832583
"$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr"
25842584
return 1
25852585
else
2586-
# Format current_version by removing the last '.0'
2587-
formatted_current_version=$(echo $current_version | awk -F. '{print $1"."$2}')
2586+
# Use awk to format the version based on the number of initial digits
2587+
formatted_current_version=$(echo "$current_version" | awk -F. '{
2588+
if (length($1) == 4 && NF >= 3) {
2589+
# For version starting with four digits like 3004.388.5.0
2590+
# Format as the next two fields (388.5)
2591+
printf "%s.%s", $2, $3
2592+
} else if (NF >= 2) {
2593+
# For version with three initial digits like 388.5.0
2594+
# Format as the first two fields (388.5)
2595+
printf "%s.%s", $1, $2
2596+
}
2597+
}')
25882598

25892599
# Format release_version by removing the prefix '3004.' and the last '.0'
25902600
formatted_release_version=$(echo $release_version | awk -F. '{print $2"."$3}')
25912601

2592-
# Extract log contents between two firmware versions
2593-
changelog_contents=$(awk "/$formatted_release_version/,/$formatted_current_version/" "$changelog_file")
2594-
2595-
# Define high-risk terms as a single string separated by '|'
2596-
high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended"
2597-
2598-
# Search for high-risk terms in the extracted log contents
2599-
if echo "$changelog_contents" | grep -Eiq "$high_risk_terms"; then
2600-
if [ "$inMenuMode" = true ]; then
2601-
printf "\n ${REDct}Warning: Found high-risk phrases in the change-logs.${NOct}"
2602-
printf "\n ${REDct}Would you like to continue anyways?${NOct}"
2603-
if ! _WaitForYESorNO_ ; then
2604-
Say "Exiting for change-log review."
2605-
_DoCleanUp_ 1 ; return 1
2602+
# Check if the current version is present in the changelog
2603+
if ! grep -qE "^${formatted_current_version} \([0-9]+[-]" "$changelog_file"; then
2604+
Say "Current version not found in change-log. Bypassing change-log verification for this run."
2605+
else
2606+
# Extract log contents between two firmware versions
2607+
changelog_contents=$(awk "/^$formatted_release_version \([0-9]+[-]/,/$formatted_current_version \([0-9]+[-]/" "$changelog_file")
2608+
2609+
# Define high-risk terms as a single string separated by '|'
2610+
high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended"
2611+
2612+
# Search for high-risk terms in the extracted log contents
2613+
if echo "$changelog_contents" | grep -Eiq "$high_risk_terms"; then
2614+
if [ "$inMenuMode" = true ]; then
2615+
printf "\n ${REDct}Warning: Found high-risk phrases in the change-logs.${NOct}"
2616+
printf "\n ${REDct}Would you like to continue anyways?${NOct}"
2617+
if ! _WaitForYESorNO_ ; then
2618+
Say "Exiting for change-log review."
2619+
_DoCleanUp_ 1 ; return 1
2620+
fi
2621+
else
2622+
Say "Warning: Found high-risk phrases in the change-logs."
2623+
Say "Please run script interactively to approve the upgrade."
2624+
_SendEMailNotification_ STOP_FW_UPDATE_APPROVAL
2625+
_DoCleanUp 1
2626+
_DoExit_ 1
26062627
fi
26072628
else
2608-
Say "Warning: Found high-risk phrases in the change-logs."
2609-
Say "Please run script interactively to approve the upgrade."
2610-
_SendEMailNotification_ STOP_FW_UPDATE_APPROVAL
2611-
_DoCleanUp 1
2612-
_DoExit_ 1
2629+
Say "No high-risk phrases found in the change-logs."
26132630
fi
2614-
else
2615-
Say "No high-risk phrases found in the change-logs."
26162631
fi
26172632
fi
26182633
else

0 commit comments

Comments
 (0)