Skip to content

Commit

Permalink
Merge branch 'main' into storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
iva2k committed Jul 19, 2024
2 parents ab3bcdf + 5a91376 commit 78b287e
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 15 deletions.
28 changes: 20 additions & 8 deletions scripts/git-merge_main-to-all-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,24 @@ function exit_save_state() {
exit $((rc))
}
function load_state() {
local file="${1:-$STATE_FILE}"
outputs=()
errors=()
tms_real=()
branches_done=()
# TARGET_BRANCHES_DEFAULT=("${TARGET_BRANCHES[@]}")
if [ -f "$STATE_FILE" ]; then
if [ -f "$file" ]; then
# shellcheck disable=SC1090
source "$STATE_FILE"
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() loaded from file $STATE_FILE."
source "$file"
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() loaded from file $file."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: outputs=${outputs[*]}."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: tms_real=${tms_real[*]}."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: errors=${errors[*]}."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: branches_done=${branches_done[*]}."
# [ "$DEBUG" -ne 0 ] && echo "DEBUG: TARGET_BRANCHES=${TARGET_BRANCHES[*]}."
# clear_state
else
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() no file $STATE_FILE."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() no file $file."
fi
}

Expand Down Expand Up @@ -140,10 +141,11 @@ function time_it() {
# Function to display usage information
function usage() {
# echo "Usage: $0 [-h] [-v] -n <name> [-a <age>]"
echo "Usage: $0 [-h] [-v] "
echo "Usage: $0 [-h] [-c] [-p]"
echo " -h: Display this help message"
# echo " -v: Enable verbose mode"
echo " -c: Continue merge after resolving conflicts"
echo " -p: Print last run summary only"
# echo " -n <name>: Specify a name (required)"
# echo " -a <age>: Specify an age (optional)"
}
Expand All @@ -152,9 +154,10 @@ function usage() {
function parse_arguments() {
local opt OPTIND OPTARG
OPTIND=1
print_last=0
continue_merge=0
# while getopts "hvcn:a:" opt; do
while getopts "hc" opt; do
while getopts "hcp" opt; do
case $opt in
h)
usage
Expand All @@ -163,6 +166,9 @@ function parse_arguments() {
c)
continue_merge=1
;;
p)
print_last=1
;;
# v)
# verbose=true
# ;;
Expand Down Expand Up @@ -528,13 +534,19 @@ main() {
exit 1
fi

load_state
mkdir -p "$(dirname "$LOGFILE")" >/dev/null
if [ "$continue_merge" -ne 0 ]; then
if [ "$print_last" -ne 0 ]; then
[ ! -f "$STATE_FILE_BACKUP" ] && { echo "No last run file \"$STATE_FILE_BACKUP\"."; exit 1; }
load_state $STATE_FILE_BACKUP
print_summary
return 0
elif [ "$continue_merge" -ne 0 ]; then
# Previous $LOGFILE is continued
load_state
continue_merge_to_all "$@"
else
echo "" >"$LOGFILE" ;# Clear Previous $LOGFILE
load_state
merge_to_all 0 "$@"
fi

Expand Down
83 changes: 76 additions & 7 deletions scripts/git-run-all-in-branches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,24 @@ function exit_save_state() {
exit $((rc))
}
function load_state() {
local file="${1:-$STATE_FILE}"
outputs=()
errors=()
tms_real=()
branches_done=()
# TARGET_BRANCHES_DEFAULT=("${TARGET_BRANCHES[@]}")
if [ -f "$STATE_FILE" ]; then
if [ -f "$file" ]; then
# shellcheck disable=SC1090
source "$STATE_FILE"
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() loaded from file $STATE_FILE."
source "$file"
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() loaded from file $file."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: outputs=${outputs[*]}."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: tms_real=${tms_real[*]}."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: errors=${errors[*]}."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: branches_done=${branches_done[*]}."
# [ "$DEBUG" -ne 0 ] && echo "DEBUG: TARGET_BRANCHES=${TARGET_BRANCHES[*]}."
# clear_state
else
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() no file $STATE_FILE."
[ "$DEBUG" -ne 0 ] && echo "DEBUG: load_state() no file $file."
fi
}

Expand Down Expand Up @@ -150,6 +151,64 @@ function time_it() {
return $return_value
}

# Function to display usage information
function usage() {
# echo "Usage: $0 [-h] [-v] -n <name> [-a <age>]"
echo "Usage: $0 [-h] [-p]"
echo " -h: Display this help message"
# echo " -v: Enable verbose mode"
# echo " -c: Continue merge after resolving conflicts"
echo " -p: Print last run summary only"
# echo " -n <name>: Specify a name (required)"
# echo " -a <age>: Specify an age (optional)"
}

# Function to parse command-line arguments
function parse_arguments() {
local opt OPTIND OPTARG
OPTIND=1
print_last=0
continue_merge=0
# while getopts "hvcn:a:" opt; do
while getopts "hp" opt; do
case $opt in
h)
usage
exit 0
;;
p)
print_last=1
;;
# v)
# verbose=true
# ;;
# n)
# name=$OPTARG
# ;;
# a)
# age=$OPTARG
# ;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
;;
esac
done

# Check if required arguments are provided
# if [ -z "$name" ]; then
# echo "Error: Name is required" >&2
# usage
# exit 1
# fi
}

# alias decolor='sed "s/\x1B\[\([0-9]\{1,2\}\(;[0-9]\{1,2\}\)\?\)\?[mGK]//g"'
function decolor() {
local input
Expand Down Expand Up @@ -339,16 +398,26 @@ function print_summary() {
}

main() {
parse_arguments "$@"

if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo >&2
echo "Error: Not a git repository" >&2
exit 1
fi

load_state
mkdir -p "$(dirname "$LOGFILE")" >/dev/null
echo "" >"$LOGFILE"
run_all 0 "$@"
if [ "$print_last" -ne 0 ]; then
[ ! -f "$STATE_FILE_BACKUP" ] && { echo "No last run file \"$STATE_FILE_BACKUP\"."; exit 1; }
load_state $STATE_FILE_BACKUP
print_summary
return 0
else
echo "" >"$LOGFILE"
load_state
run_all 0 "$@"
fi

print_summary
rc="$?"

Expand Down

0 comments on commit 78b287e

Please sign in to comment.