From 845e27f6901e8c440797a9c52c1517a2ad81e153 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Tue, 14 Nov 2017 21:16:48 -0500 Subject: [PATCH] new script puffer corresponds to checkin and getem puffer is the non-recursing script based on REPOSITORY_LIST, so you can just say "puffer" with no arguments to get your repositories up to date and merged. --- scripts/rev_control/puffer.sh | 32 +++++++++ scripts/rev_control/version_control.sh | 96 ++++++++++++++++++++------ 2 files changed, 105 insertions(+), 23 deletions(-) create mode 100644 scripts/rev_control/puffer.sh diff --git a/scripts/rev_control/puffer.sh b/scripts/rev_control/puffer.sh new file mode 100644 index 00000000..c02ef3bc --- /dev/null +++ b/scripts/rev_control/puffer.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# puffer: "puffs out" all of the folders present in the REPOSITORY_LIST +# variable, which causes the repo to be merged with its remote versions. +# this enables a clean check-in; after puffer runs, there will be no secret +# upstream changes that could mess up the git push (svn and cvs are not +# supported in this script, since they branch differently than git). + +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" + +############## + +echo "puffing out repositories at: $(date)" +echo + +FULL_LIST=" $(dirname $FEISTY_MEOW_APEX) $HOME " +if [ "$OS" == "Windows_NT" ]; then + FULL_LIST+=" c:/ d:/ e:/ " +fi + +puff_out_list $FULL_LIST +test_or_die "puffing out list: $FULL_LIST" + +############## + +# regenerate the scripts after puffing out, since this could mean a modified version +# of feisty meow is present. +regenerate + +############## + diff --git a/scripts/rev_control/version_control.sh b/scripts/rev_control/version_control.sh index 5c343b5d..6396a88a 100644 --- a/scripts/rev_control/version_control.sh +++ b/scripts/rev_control/version_control.sh @@ -96,8 +96,19 @@ function do_checkin() # see if there are any changes in the local repository. if ! git diff-index --quiet HEAD --; then # tell git about all the files and get a check-in comment. +#hmmm: begins to look like, you guessed it, a reusable bit that all commit actions could enjoy. git commit . - test_or_die "git commit" + retval=$? + test_or_continue "git commit" + if [ $retval -ne 0 ]; then + echo -e -n "Commit failed or was aborted:\nShould we continue with other check-ins? [y/N] " + local line + read line + if [[ "${line:0:1}" != "y" ]]; then + echo "Stopping check-in process due to missing commit and user request." + exit 1 + fi + fi fi # a new set of steps we have to take to make sure the branch integrity is good. @@ -179,7 +190,7 @@ function do_report_new return 0 } -# checks in all the folders in a specified list. +# checks in all the folders in the specified list. function checkin_list() { # make the list of directories unique. @@ -197,7 +208,7 @@ function checkin_list() if [[ $outer =~ /.* ]]; then # yep, this path is absolute. just handle it directly. if [ ! -d "$outer" ]; then continue; fi - do_checkin $outer + do_checkin "$outer" test_or_die "running check-in (absolute) on path: $outer" sep 28 else @@ -205,7 +216,7 @@ function checkin_list() # add in the directory component to see if we can find the folder. local path="$inner/$outer" if [ ! -d "$path" ]; then continue; fi - do_checkin $path + do_checkin "$path" test_or_die "running check-in (relative) on path: $path" sep 28 done @@ -215,24 +226,62 @@ function checkin_list() restore_terminal_title } -# takes out the first few carriage returns that are in the input. -function squash_first_few_crs() +# does a careful git update on all the folders in the specified list. +function puff_out_list() { - i=0 - while read input_text; do - i=$((i+1)) - if [ $i -le 5 ]; then - echo -n "$input_text " + # make the list of directories unique. + local list="$(uniquify $*)" + + save_terminal_title + + # turn repo list back into an array. + eval "repository_list=( ${REPOSITORY_LIST[*]} )" + + local outer inner + +#hmmm: once again, seeing some reusable code in this loop... + for outer in "${repository_list[@]}"; do + # check the repository first, since it might be an absolute path. + if [[ $outer =~ /.* ]]; then + # yep, this path is absolute. just handle it directly. + if [ ! -d "$outer" ]; then continue; fi + do_careful_git_update "$outer" + test_or_die "running puff-out (absolute) on path: $outer" + sep 28 else - echo $input_text + for inner in $list; do + # add in the directory component to see if we can find the folder. + local path="$inner/$outer" + if [ ! -d "$path" ]; then continue; fi + do_careful_git_update "$path" + test_or_die "running puff-out (relative) on path: $path" + sep 28 + done fi done - if [ $i -le 3 ]; then - # if we're still squashing eols, make sure we don't leave them hanging. - echo - fi + + restore_terminal_title } +#hmmm: to go below. +### takes out the first few carriage returns that are in the input. +##function squash_first_few_crs() +##{ + ##i=0 + ##while read input_text; do + ##i=$((i+1)) + ##if [ $i -le 5 ]; then + ##echo -n "$input_text " + ##else + ##echo $input_text + ##fi + ##done + ##if [ $i -le 3 ]; then + ### if we're still squashing eols, make sure we don't leave them hanging. + ##echo + ##fi +##} + #hmmm: the below are git specific and should be named that way. function all_branch_names() @@ -275,16 +324,19 @@ function check_branch_state() local remote_branch=$(git rev-parse "$branch") local merge_base=$(git merge-base @ "$branch") + local to_echo= if [ "$local_branch" == "$remote_branch" ]; then - echo "okay" + to_echo="okay" elif [ "$local_branch" == "$merge_base" ]; then - echo "needs_pull" + to_echo="needs_pull" elif [ "$remote_branch" == "$merge_base" ]; then - echo "needs_push" + to_echo="needs_push" else - echo "diverged" + to_echo="diverged" fi + echo -n "$to_echo" + return $to_return } @@ -294,7 +346,7 @@ function show_branch_conditionally() { local this_branch="$1"; shift - state=$(check_branch_state "$this_branch") + local state=$(check_branch_state "$this_branch") if [ "$state" != "okay" ]; then echo "=> branch '$this_branch' state is not clean: $state" fi @@ -342,8 +394,6 @@ function do_careful_git_update() # we are pretty sure the remote branch does exist. git pull --no-ff origin "$bran" | $TO_SPLITTER promote_pipe_return 0 - - echo "=> branch '$bran' state after pull is: $state" fi test_or_die "git pull of remote branch: $bran" done -- 2.34.1