=various edits and improvments

This commit is contained in:
Gal Szkolnik 2022-09-21 01:54:10 -04:00
parent 71e8da7289
commit f38f61cc6d
6 changed files with 230 additions and 191 deletions

View file

@ -0,0 +1,16 @@
#! /usr/bin/env bash
pushd . > /dev/null
cd $(git rev-parse --show-toplevel)
ARCHIVE=${1:-/tmp/$(basename $PWD .git)-$(git branch --show-current).git}
[[ -d "$ARCHIVE" || "$ARCHIVE" != "${ARCHIVE%/}" ]] \
&& ARCHIVE=${1%/}/$(basename $PWD .git)-$(git branch --show-current).git
DIRNAME=$(dirname $ARCHIVE)
[[ ! -d "$DIRNAME" ]] \
&& echo "Directory $DIRNAME is missing, creating it..." \
&& mkdir -p $DIRNAME
ARCHIVE=$DIRNAME/$(basename $ARCHIVE .tgz).tgz
printf "Archiving into %s...\n\n" "$ARCHIVE"
tar czvf $ARCHIVE $(git diff --diff-filter=ACMRT --name-only "${@:2}") \
&& printf "\nDone.\n\n"
popd > /dev/null