Commit bf0fc3da authored by Vitaly Lipatov's avatar Vitaly Lipatov

gpush: rewrite girar/branch detection part, refactoring

parent 84d52ce6
...@@ -65,33 +65,49 @@ push_to_remote() ...@@ -65,33 +65,49 @@ push_to_remote()
[ -z "$TAGSALL" ] || git push --tags $GHOST $CURRENTBRANCH [ -z "$TAGSALL" ] || git push --tags $GHOST $CURRENTBRANCH
} }
do_push() tune_girarlist()
{ {
REMOTELIST="$(get_remote_git_list)" REMOTELIST="$(get_remote_git_list)"
GIRARHOST=$1 NEWGIRAR=$1
shift
# use one target if it one # If run with gear as param
if is_one_girar_name "$REMOTELIST" && [ -z "$GIRARHOST" ] ; then if [ -n "$NEWGIRAR" ] ; then
GIRARHOST="$REMOTELIST" # if run with girar host in arg
fi if is_girar_name "$NEWGIRAR" ; then
# origin by default if exists and alone # if remote list is empty, do ginit
if [ -z "$GIRARHOST" ] && [ "$(git remote | uniq)" = "origin" ] ; then [ -n "$REMOTELIST" ] || ginit $NEWGIRAR
GIRARHOST="origin" fi
LISTGIRARHOST="$NEWGIRAR"
shift
else
# use one target if it one
if is_one_girar_name "$REMOTELIST" ; then
GIRARHOST="$REMOTELIST"
fi
# origin by default if exists and alone
if [ "$(get_remote_repo_list)" = "origin" ] ; then
GIRARHOST="origin"
fi
LISTGIRARHOST="$GIRARHOST $(do_exclude_list "$GIRARHOST" "$REMOTELIST")"
fi fi
CURRENTBRANCH=$(get_current_branch)
# if set it can be tag # if set it can be tag or branch name
if [ -n "$1" ] ; then if [ -n "$1" ] ; then
CURRENTBRANCH="$1" CURRENTBRANCH="$1"
shift shift
else
CURRENTBRANCH=$(get_current_branch)
fi fi
[ -n "$CURRENTBRANCH" ] || fatal "Can't detect current branch" [ -n "$CURRENTBRANCH" ] || fatal "Can't detect current branch"
}
tune_girarlist $LISTARGS
if [ "$PUSHALL" = "--all" ] ; then if [ "$PUSHALL" = "--all" ] ; then
TEXTBRANCH="all branches" TEXTBRANCH="all branches"
...@@ -103,16 +119,6 @@ else ...@@ -103,16 +119,6 @@ else
fi fi
fi fi
# if remote list is empty, do ginit
[ -n "$REMOTELIST" ] || ginit $GIRARHOST
LISTGIRARHOST="$GIRARHOST $(do_exclude_list "$GIRARHOST" "$REMOTELIST")"
[ -n "$OVERRIDEGIRARHOST" ] && LISTGIRARHOST=$OVERRIDEGIRARHOST
for i in $LISTGIRARHOST ; do for i in $LISTGIRARHOST ; do
push_to_remote $i push_to_remote $i
done done
}
do_push $LISTARGS
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment