diff --git a/README.md b/README.md index 55bc400..6f73a24 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,11 @@ Usage: octozipo [OPTION...] example: octozipo -s _ example: octozipo --spacer=_ ====================================================== + --git-date= + set the git commit date + default: Actual Date + example: octozipo --git-date="Feb 14 03:18:31" + ====================================================== --keep-repo switch to keep the repository directory example: octozipo --keep-repo @@ -118,7 +123,7 @@ Usage: octozipo [OPTION...] example: octozipo -h example: octozipo --help ====================================================== - Octozipo v1.1.0 + Octozipo v2.0.0 ====================================================== ``` ### Example diff --git a/src/octozipo b/src/octozipo index 2866330..812f34e 100755 --- a/src/octozipo +++ b/src/octozipo @@ -470,6 +470,7 @@ VDM_SPACER='-' DRY=false QUIET=false DEBUG=false +GIT_DATE_FORMAT="%b %e %X %Y %z" # help message ʕ•ᴥ•ʔ function show_help() { @@ -516,6 +517,11 @@ Usage: ${PROGRAM_CODE} [OPTION...] example: ${PROGRAM_CODE} -s _ example: ${PROGRAM_CODE} --spacer=_ ====================================================== + --git-date= + set the git commit date + default: Actual Date + example: ${PROGRAM_CODE} --git-date="Feb 14 03:18:31" + ====================================================== --keep-repo switch to keep the repository directory example: ${PROGRAM_CODE} --keep-repo @@ -631,6 +637,22 @@ while :; do _echo '[error] "--org=" requires a non-empty option argument.' exit 17 ;; + --git-date) # Takes an option argument; ensure it has been specified. + if [ "$2" ]; then + VDM_GIT_DATE=$2 + shift + else + _echo '[error] "--git-date" requires a non-empty option argument.' + exit 17 + fi + ;; + --git-date=?*) + VDM_GIT_DATE=${1#*=} # Delete everything up to "=" and assign the remainder. + ;; + --git-date=) # Handle the case of an empty --packages= + _echo '[error] "--git-date=" requires a non-empty option argument.' + exit 17 + ;; -s | --spacer) # Takes an option argument; ensure it has been specified. if [ "$2" ]; then VDM_SPACER=$2 @@ -714,6 +736,21 @@ tmp_path="$VDM_ZIP_DIR/.${PROGRAM_CODE}.mapper" # done with the tmp_path unset tmp_path +# set the git date +if [ -n "$VDM_GIT_DATE" ]; then + # make sure the format is correct + GIT_AUTHOR_DATE=$( date --date="$VDM_GIT_DATE" +"$GIT_DATE_FORMAT") +else + # set today's date + GIT_AUTHOR_DATE=$( date +"$GIT_DATE_FORMAT") +fi +# set the git committer date +GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" + +# now make globally available to git +export GIT_AUTHOR_DATE +export GIT_COMMITTER_DATE + # dynamic defaults VDM_PATH_REPO='' VDM_PATH_ZIP='' @@ -747,6 +784,9 @@ cat < VALUE: $VDM_SPACER ====================================================== + --git-date= + VALUE: $VDM_GIT_DATE + ====================================================== --keep-repo VALUE: $VDM_KEEP_REPO ====================================================== @@ -773,3 +813,7 @@ fi # run main main + +# clear globals +unset GIT_AUTHOR_DATE +unset GIT_COMMITTER_DATE \ No newline at end of file