Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Created June 17, 2020 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickboldt/4f5bf0ace88dcfd2b7f4779be23146f7 to your computer and use it in GitHub Desktop.
Save nickboldt/4f5bf0ace88dcfd2b7f4779be23146f7 to your computer and use it in GitHub Desktop.
script to update webtools project submodules and commit changes into the parent project, releng.aggregator
#!/bin/bash
if [[ $1 ]]; then DIR=$1; else DIR=${HOME}/we/rel.agg; fi
if [[ $2 ]]; then branch=$2; else branch=master; fi
GITUNALL ()
{
git checkout -- .; git reset HEAD .; git clean -fdx
}
GPUOM ()
{
branch_wanted=$1
if [[ ! $(git branch | grep ${branch_wanted}) ]]; then
git checkout master; git pull --rebase origin master -p
else
git checkout ${branch_wanted}; git pull --rebase origin ${branch_wanted} -p
fi
}
GD ()
{
git diff --color=always -w $1
}
cd ${DIR}; for d in webtools.*; do
# pull latest from origin master
pushd $d
echo ""; echo " ==UP== $d ==UP=="
GITUNALL; GITUNALL; GPUOM ${branch}
popd >/dev/null
done
cd ${DIR}; for d in webtools.*; do
# if there are changes in submodules
if [[ $(GD $d) ]]; then
echo ""; echo " ==OM== $d ==OM==" ; GD $d; echo ""
pushd $d
git lg -5; echo ""
HEAD_COMMIT=$(git log | head -1 | sed -e "s/commit //")
if [[ ! $(git branch | grep ${branch}) ]]; then
branch_used=master
else
branch_used=${branch}
fi
git reset origin/${branch_used}; # git lg -5; echo ""
OM_COMMIT=$(git log | head -1 | sed -e "s/commit //")
# git log | head -1
popd >/dev/null
git commit -s -m "${d} :: pull latest commits(s) from origin/${branch_used} up to ${OM_COMMIT}" ${d}
pushd $d; git reset ${HEAD_COMMIT}; git lg -5; echo ""; popd >/dev/null
fi
done
echo ""
echo " == releng.aggregator == "
echo ""
git lg -15; echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment