Commit d5b62a51 authored by Vitaly Lipatov's avatar Vitaly Lipatov

introduce get_type_by_current_branch, use it for branch detecting

add test for get current type from branch
parent 1ca09e66
......@@ -3,6 +3,8 @@
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
load_mod git
is_alt()
{
test -f /etc/altlinux-release
......@@ -12,6 +14,7 @@ is_alt()
# Internal
set_target_type()
{
# check for M51 and so on
if echo $1 | grep "^M[0-9][0-9]$" >/dev/null ; then
MENV=$1
return 0
......@@ -25,25 +28,30 @@ set_target_type()
return 1;
}
set_incoming()
get_type_by_git_branch_name()
{
INCOMING="Sisyphus"
test -z "$1" && return
case "$1" in
("DD")
INCOMING="Daedalus"
;;
("SS")
INCOMING="Sisyphus"
;;
*)
if [ -n "$UPDATES" ] ; then
INCOMING="updates/`get_altdistr_version $1`"
else
INCOMING="backports/`get_altdistr_version $1`"
fi
;;
esac
if [ "$1" = "p5" ] ; then
echo "M50"
return
fi
# like 5.1
if echo $1 | grep -q "^[0-9].[0-9]$" ; then
get_altdistr_mod $1
return
fi
# like M50
if echo $1 | grep -q "^M[0-9][0-9]$" ; then
get_altdistr_mod ${1/^M/}
return
fi
}
get_type_by_current_branch()
{
local BRANCH=$(get_current_branch)
get_type_by_git_branch_name $BRANCH
}
set_binaryrepo()
......
......@@ -167,9 +167,12 @@ fi
[ "$1" = "--help" ] && mygetopts -h
# Sisyphus by default
# Build for Sisyphus by default
MENV=SS
set_target_type $(basename `pwd`)
if is_gear ; then
# Set target according to current branch
set_target_type $(get_type_by_current_branch)
fi
LISTNAMES=
LISTARGS=
......
#!/bin/sh
. `dirname $0`/../share/eterbuild/functions/common
load_mod git alt
check()
{
[ "$2" != "$3" ] && echo "FATAL with '$1': result '$3' do not match with '$2'" || echo "OK for '$1' with '$2'"
}
echo "Current git branch: $(get_current_branch)"
check 1 M40 $(get_type_by_git_branch_name 4.0)
check 1 M40 $(get_type_by_git_branch_name M40)
check 1 M50 $(get_type_by_git_branch_name p5)
check 1 M50 $(get_type_by_git_branch_name M50)
check 1 M50 $(get_type_by_git_branch_name 5.0)
check 1 M51 $(get_type_by_git_branch_name M51)
check 1 M51 $(get_type_by_git_branch_name 5.1)
check 1 "" $(get_type_by_git_branch_name master)
check 1 "" $(get_type_by_git_branch_name sisyphus)
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