Update byof scripts

This commit is contained in:
William Blake Galbreath
2020-07-02 20:35:42 -05:00
parent 7a778f7212
commit 140a58f451
9 changed files with 271 additions and 266 deletions

View File

@@ -7,39 +7,39 @@ basedir=$(pwd -P)
cd - || exit
function bashColor() {
if [ "$2" ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
if [ "$2" ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
}
function bashColorReset() {
echo -e "\e[m"
echo -e "\e[m"
}
function cleanupPatches() {
cd "$1" || exit
for patch in *.patch; do
gitver=$(tail -n 2 "$patch" | grep -ve "^$" | tail -n 1)
diffs=$(git diff --staged "$patch" | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index|Date\: )")
cd "$1" || exit
for patch in *.patch; do
gitver=$(tail -n 2 "$patch" | grep -ve "^$" | tail -n 1)
diffs=$(git diff --staged "$patch" | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index|Date\: )")
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
if [ "x$testver" != "x" ]; then
diffs=$(echo "$diffs" | tail -n +3)
fi
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
if [ "x$testver" != "x" ]; then
diffs=$(echo "$diffs" | tail -n +3)
fi
if [ "x$diffs" == "x" ]; then
git reset HEAD "$patch" >/dev/null
git checkout -- "$patch" >/dev/null
fi
done
if [ "x$diffs" == "x" ]; then
git reset HEAD "$patch" >/dev/null
git checkout -- "$patch" >/dev/null
fi
done
}
function basedir() {
cd "$basedir" || exit
cd "$basedir" || exit
}
function gethead() {
(
cd "$1" || exit
git log -1 --oneline
)
(
cd "$1" || exit
git log -1 --oneline
)
}