Commit b01adf63 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmbph: rewrite branch functions

parent ce0688f8
...@@ -107,18 +107,23 @@ if [ "$PKGVENDOR" = "alt" ] && is_gear $SPECDIR ; then ...@@ -107,18 +107,23 @@ if [ "$PKGVENDOR" = "alt" ] && is_gear $SPECDIR ; then
set_specdir $SPEC set_specdir $SPEC
docmd cd $SPECDIR || fatal docmd cd $SPECDIR || fatal
# set USEBRANCH
set_usebranch
# spec name for branch # spec name for branch
BPSPEC=$SPEC.$USEBRANCH BPSPEC=$SPEC.$USEBRANCH
set_currentbranch
#[ -f "$BPSPEC" ] && fatal "File $BPSPEC is already exists, check it and remove" #[ -f "$BPSPEC" ] && fatal "File $BPSPEC is already exists, check it and remove"
cp -f $SPEC $BPSPEC || fatal "Can't copy to $BPSPEC" cp -f $SPEC $BPSPEC || fatal "Can't copy to $BPSPEC"
# set USEBRANCH CURBRANCH
# checkout to $USERBRANCH
checkout_bpbranch
# backport spec # backport spec
docmd $ETERBUILDBIN/rpmbps -b $BINARYREPO $BPSPEC || fatal docmd $ETERBUILDBIN/rpmbps -b $BINARYREPO $BPSPEC || fatal
# checkout to $USEBRANCH
checkout_bpbranch
# TODO: check result message for merge? # TODO: check result message for merge?
# Use heads/ against warning: refname 'branch-name' is ambiguous # Use heads/ against warning: refname 'branch-name' is ambiguous
docmd git merge --no-ff heads/$CURBRANCH docmd git merge --no-ff heads/$CURBRANCH
...@@ -141,16 +146,6 @@ if [ "$PKGVENDOR" = "alt" ] && is_gear $SPECDIR ; then ...@@ -141,16 +146,6 @@ if [ "$PKGVENDOR" = "alt" ] && is_gear $SPECDIR ; then
docmd $BUILDCOMMAND -b $BINARYREPO $LISTRPMARGS $LISTNAMES docmd $BUILDCOMMAND -b $BINARYREPO $LISTRPMARGS $LISTNAMES
RET=$? RET=$?
for SPEC in $LISTNAMES ; do
set_specdir $SPEC
docmd cd $SPECDIR || fatal
# return to CURBRANCH
checkout_original_branch || RET=$?
cd - >/dev/null
done
exit $RET exit $RET
fi fi
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
# Author: Vitaly Lipatov <lav@etersoft.ru> # Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain # Public domain
# used: BINARYREPO MDISTR BPSPEC # used: BINARYREPO MDISTR
# set: USEBRANCH CURBRANCH # set: USEBRANCH OLDBRANCH
checkout_bpbranch() set_usebranch()
{ {
#local OLDBRANCH
#[ -f "$LISTNAMES" ] || fatal "Run with one spec inside gear repo" #[ -f "$LISTNAMES" ] || fatal "Run with one spec inside gear repo"
USEBRANCH=$BINARYREPO USEBRANCH=$BINARYREPO
...@@ -20,22 +21,35 @@ checkout_bpbranch() ...@@ -20,22 +21,35 @@ checkout_bpbranch()
USEBRANCH=$OLDBRANCH USEBRANCH=$OLDBRANCH
fi fi
fi fi
}
CURBRANCH=$(cat $(get_root_git_dir)/.git/.rpmbph.current 2>/dev/null) # used: USEBRANCH OLDBRANCH BPSPEC
if [ -n "$CURBRANCH" ] ; then # set: CURBRANCH
set_currentbranch()
{
CURBRANCH=$(get_current_branch)
local cb
cb=$(cat $(get_root_git_dir)/.git/.rpmbph.current 2>/dev/null)
if [ -n "$cb" ] ; then
echog "Autorestore from broken build..." echog "Autorestore from broken build..."
docmd git checkout $CURBRANCH docmd git checkout $cb || fatal
CURBRANCH=$cb
rm -fv $(get_root_git_dir)/.git/.rpmbph.current rm -fv $(get_root_git_dir)/.git/.rpmbph.current
#rm -fv $BPSPEC $BPSPEC.* #rm -fv $BPSPEC $BPSPEC.*
rm -fv $BPSPEC.* [ -n "$BPSPEC" ] && rm -fv $BPSPEC.*
fi fi
CURBRANCH=$(get_current_branch)
# TODO: move to a separate function
if [ "$CURBRANCH" = "$USEBRANCH" ] || [ "$CURBRANCH" = "$OLDBRANCH" ] ; then if [ "$CURBRANCH" = "$USEBRANCH" ] || [ "$CURBRANCH" = "$OLDBRANCH" ] ; then
fatal "You are already in backported branch $CURBRANCH. Run rpmbph in sisyphus or master branch only." fatal "You are already in backported branch $CURBRANCH. Run rpmbph in sisyphus or master branch only."
fi fi
}
# used: USEBRANCH
checkout_bpbranch()
{
# TODO
[ -n "$CURBRANCH" ] || fatal "use assert in checkout_bpbranch"
echo "$CURBRANCH" > $(get_root_git_dir)/.git/.rpmbph.current echo "$CURBRANCH" > $(get_root_git_dir)/.git/.rpmbph.current
...@@ -47,10 +61,26 @@ checkout_bpbranch() ...@@ -47,10 +61,26 @@ checkout_bpbranch()
fi fi
} }
# used: USEBRNACH
# set: CURBRANCH
checkout_usebranch()
{
CURBRANCH=$(get_current_branch)
if [ "$USEBRANCH" = "$CURBRANCH" ] ; then
# let's think we called from rpmbph
return
fi
checkout_bpbranch
}
checkout_original_branch() checkout_original_branch()
{ {
local CURBRANCH local CURBRANCH
CURBRANCH=$(cat $(get_root_git_dir)/.git/.rpmbph.current) CURBRANCH=$(cat $(get_root_git_dir)/.git/.rpmbph.current 2>/dev/null)
[ -z "$CURBRANCH" ] && return
rm -f $(get_root_git_dir)/.git/.rpmbph.current rm -f $(get_root_git_dir)/.git/.rpmbph.current
docmd git checkout $CURBRANCH docmd git checkout $CURBRANCH
} }
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