Allow to use git-hub, if availlable
This commit is contained in:
@@ -10,28 +10,35 @@ if [ -z "`git --version`" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! git diff --exit-code > /dev/null || ! git diff --staged --exit-code > /dev/null ; then
|
||||
git=git
|
||||
if hub --version 2> /dev/null > /dev/null; then
|
||||
case "$(hub --version)" in
|
||||
*hub\ version*) git=hub;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ! ${git} diff --exit-code > /dev/null || ! ${git} diff --staged --exit-code > /dev/null ; then
|
||||
echo 'Your working directory contains local modifications!' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "`git rev-parse --show-toplevel`"
|
||||
cd "`${git} rev-parse --show-toplevel`"
|
||||
|
||||
if [ -n "`git ls-files --other --exclude-standard --exclude=build\*`" ]; then
|
||||
if [ -n "`${git} ls-files --other --exclude-standard --exclude=build\*`" ]; then
|
||||
echo 'You have untracked files!' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
branch=$1
|
||||
if ! git rev-parse "$branch" > /dev/null 2>&1; then
|
||||
echo "\"$branch\" is not a valid branch!" >&2
|
||||
exit 1
|
||||
fi
|
||||
# if ! ${git} rev-parse "$branch" > /dev/null 2>&1; then
|
||||
# echo "\"$branch\" is not a valid branch!" >&2
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
trap 'echo "(aborting the merge now)" && git merge --abort' EXIT
|
||||
trap 'echo "(aborting the merge now)" && ${git} merge --abort' EXIT
|
||||
|
||||
echo ".. Test merging of the branch \"$branch\"..."
|
||||
git merge --no-ff --no-commit "$branch" && git status && git diff --staged --summary
|
||||
${git} merge --no-ff --no-commit "$branch" && ${git} status && ${git} diff --staged --summary
|
||||
|
||||
if true; then # REMOVE
|
||||
echo '.. Testing permissions...'
|
||||
@@ -39,9 +46,9 @@ detect_wrong_permissions || exit 1
|
||||
|
||||
echo '.. Testing licenses...'
|
||||
detect_packages_licenses || exit 1
|
||||
if ! git diff --exit-code > /dev/null; then
|
||||
if ! ${git} diff --exit-code > /dev/null; then
|
||||
echo '=> There are modifications in licenses:'
|
||||
git status --porcelain
|
||||
${git} status --porcelain
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -52,12 +59,11 @@ if [ -d build ] && \
|
||||
[ -f build/CMakeCache.txt ] && \
|
||||
[ "$(grep -c -iE 'WITH_(demos|examples|tests):BOOL=(ON|TRUE|1)' build/CMakeCache.txt)" -eq "3" ]; then
|
||||
echo '.. Testing CMake configuration...'
|
||||
cmake_output=( ${(f)"$(cmake build >/dev/null 2>&1)"} )
|
||||
cmake_output=$(cmake build 2>&1)
|
||||
cmake_exit_code=$?
|
||||
if [ "$cmake_exit_code" -ne 0 ]; then
|
||||
echo 'CMake error:'
|
||||
string=${(F)cmake_output}
|
||||
echo $string
|
||||
printf '%s\n' "${cmake_output}"
|
||||
exit 1
|
||||
else
|
||||
echo OK
|
||||
@@ -68,7 +74,7 @@ else
|
||||
fi
|
||||
|
||||
echo '.. List of new files (please check that it is the expected list:'
|
||||
new_files=( ${(f)"$(git status --porcelain | grep -E '^A')"} )
|
||||
new_files=( ${(f)"$(${git} status --porcelain | grep -E '^A')"} )
|
||||
if [ ${#new_files[@]} -gt 0 ]; then
|
||||
string=${(F)new_files}
|
||||
echo $string
|
||||
@@ -76,17 +82,17 @@ else
|
||||
echo 'No new files.'
|
||||
fi
|
||||
|
||||
current_rev=$(git rev-parse HEAD)
|
||||
trap 'echo "(aborting the merge now)" && git reset --quiet --hard ${current_rev}' EXIT
|
||||
current_rev=$(${git} rev-parse HEAD)
|
||||
trap 'echo "(aborting the merge now)" && ${git} reset --quiet --hard ${current_rev}' EXIT
|
||||
|
||||
echo '.. Dummy merge commit...'
|
||||
conflicts=( ${(f)"$(git status --porcelain | awk '/^[^ ][^ ]/ {print $2}')"} )
|
||||
if [ ${#conflicts[@]} -gt 0 ]; then git add $conflicts || exit 1; fi
|
||||
git commit -m 'dummy merge commit' || exit 1
|
||||
conflicts=( ${(f)"$(${git} status --porcelain | awk '/^[^ ][^ ]/ {print $2}')"} )
|
||||
if [ ${#conflicts[@]} -gt 0 ]; then ${git} add $conflicts || exit 1; fi
|
||||
${git} commit -m 'dummy merge commit' || exit 1
|
||||
|
||||
echo '.. Size of the gzipped bundle'
|
||||
trap 'echo "(aborting the merge now)" && rm bundle.gz && git reset --quiet --hard ${current_rev}' EXIT
|
||||
git bundle create bundle ${current_rev}..HEAD > /dev/null 2>&1 && gzip bundle || exit 1
|
||||
trap 'echo "(aborting the merge now)" && rm bundle.gz && ${git} reset --quiet --hard ${current_rev}' EXIT
|
||||
${git} bundle create bundle ${current_rev}..HEAD > /dev/null 2>&1 && gzip bundle || exit 1
|
||||
size=$(zstat +size bundle.gz)
|
||||
echo "=> $size"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user