#!/bin/zsh # vim: set shiftwidth=4 softtabstop=4 tabstop=4 expandtab: # # This script update another repository that is a copy of the sources # # Assertion: # - the source project already exist on bitbucket and its name is the same as the metaproject+_sources # - the metaproject is the same type as the sources one here=$(dirname $0) project_home=$(cd $here && cd .. && echo $PWD) project_name=$(basename $project_home) source_name=${project_name}_sources $here/list_modules odoo_modules=($(python3 -B -c "import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'modules') and ' '.join(c.get('odoo_scripts', 'modules').split()) or '' )")) dependencies=($(python3 -B -c "import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'dependencies') and ' '.join(c.get('odoo_scripts', 'dependencies').split()) or '' )")) other_sources=($(python3 -B -c "import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'other_sources') and ' '.join(c.get('odoo_scripts', 'other_sources').split()) or '' )")) # color stuff autoload colors && colors for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do eval $COLOR='$fg_no_bold[${(L)COLOR}]' eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]' done eval RESET='$reset_color' pushd $project_home if [ -e ".hg" ]; then branch="$(hg id -b)" tags=($(hg id -t)) hg clone ssh://hg@bitbucket.org/xcg/${source_name} || exit 1 pushd $source_name hg update $branch branch_exist=$? popd echo "${YELLOW}INFO ${RESET} - branch_exist=$branch_exist" # Remove any content inside it rm -rf ${source_name}/* rsync -rRLt --exclude='.hg*' --exclude='.git' $(eval echo $odoo_modules $dependencies $other_sources) $source_name pushd $source_name hg addremove if [[ "x$branch_exist" != "x0" ]]; then hg branch $branch fi hg commit -m"Update sources" # Tagging process only works if done locally if [[ "$tags" != "tip" ]]; then id_to_tag=$(hg id -i) for tag in $tags; do echo "${YELLOW}INFO ${RESET} - Add tag $tag" hg tag $tag -r $id_to_tag done fi if [[ "x$branch_exist" != "x0" ]]; then echo "${YELLOW}INFO ${RESET} - Pushing new branch $branch" hg push --new-branch --publish else echo "${YELLOW}INFO ${RESET} - Pushing branch $branch" hg push --publish fi popd rm -rf ${source_name} else echo "${RED}ERROR${RESET} - Repository VCS unknown/not handled" popd exit 1 fi popd