- Be more verbose in error and progress messages

Signed-off-by: Matt Darfeuille <matd...@gmail.com>
---
 build/release | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/build/release b/build/release
index 8c6fb52d..ea862a33 100755
--- a/build/release
+++ b/build/release
@@ -166,13 +166,23 @@ push_command_func() # $1 = Path of repository, $2 = 
remote, $3 = branch
     if [ -n "$3" ]; then
         echo "Pushing branch $3 from ${1}/.git to ${2}..."
 
-        git --git-dir=${1}/.git --work-tree=$1 push --quiet --follow-tags $2 $3
-        [ $? -ne 0 ] && fatal_error "Failed to push branch $3 from ${1}/.git 
to ${2}."
+       if git --git-dir=${1}/.git --work-tree=$1 ls-remote --heads --exit-code 
--quiet $2 refs/heads/$3 1> /dev/null; then
+           git --git-dir=${1}/.git --work-tree=$1 push --quiet --follow-tags 
$2 $3
+           [ $? -ne 0 ] && fatal_error "Failed to push branch $3 from 
${1}/.git to ${2}."
+       else
+           git --git-dir=${1}/.git --work-tree=$1 push --quiet --follow-tags 
-set-upstream $2 $3
+           [ $? -ne 0 ] && fatal_error "Failed to push branch $3 from 
${1}/.git to ${2}."
+       fi
     else
-        echo "Pushing checked out branch from ${1}/.git to ${2}..."
-
-        git --git-dir=${1}/.git --work-tree=$1 push --quiet --follow-tags $2
-        [ $? -ne 0 ] && fatal_error "Failed to push checked out branch from 
${1}/.git to ${2}."
+       echo "Pushing checked out branch (${BASEVERSION}) from ${1}/.git to 
${2}..."
+
+       if git --git-dir=${1}/.git --work-tree=$1 ls-remote --heads --exit-code 
--quiet $2 refs/heads/$BASEVERSION 1> /dev/null; then
+           git --git-dir=${1}/.git --work-tree=$1 push --quiet --follow-tags $2
+           [ $? -ne 0 ] && fatal_error "Failed to push checked out branch from 
${1}/.git to ${2}."
+       else
+           git --git-dir=${1}/.git --work-tree=$1 push --quiet --follow-tags 
--set-upstream $2 $BASEVERSION
+           [ $? -ne 0 ] && fatal_error "Failed to push checked out branch 
(${BASEVERSION}) from ${1}/.git to ${2}."
+       fi
     fi
 }
 
-- 
2.11.0



_______________________________________________
Shorewall-devel mailing list
Shorewall-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shorewall-devel

Reply via email to