Blame Automation/Modules/centos-art.sh-vcs/vcs.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# vcs.sh -- This function standardizes version control tasks inside
Alain Reguera Delgado 8f60cb
# the repository.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
# $Id$
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function vcs {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    local ACTIONNAM=''
Alain Reguera Delgado 8f60cb
    local ACTIONNAMS=''
Alain Reguera Delgado 8f60cb
    local ACTIONVAL=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify whether version control actions should be performed or
Alain Reguera Delgado 8f60cb
    # not inside the repository directory structure.
Alain Reguera Delgado 8f60cb
    local ENABLED=$(cli_getConfigValue "${CLI_BASEDIR}/${CLI_NAME}.conf" "version_control" "enabled")
Alain Reguera Delgado 8f60cb
    if [[ ! ${ENABLED} =~ '^(yes|ye|y|1)$' ]];then
Alain Reguera Delgado 8f60cb
        return
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize version control system to use inside the repository.
Alain Reguera Delgado 8f60cb
    local PACKAGE=$(cli_getConfigValue "${CLI_BASEDIR}/${CLI_NAME}.conf" "version_control" "package")
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Set possible values to packages used as version control system.
Alain Reguera Delgado 8f60cb
    if [[ ${PACKAGE} =~ '^(git|subversion)$' ]];then
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Initialize the absolute path to commands we'll use as
Alain Reguera Delgado 8f60cb
        # version control system in the working copy.
Alain Reguera Delgado 8f60cb
        case ${PACKAGE} in
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            'git' )
Alain Reguera Delgado 8f60cb
                COMMAND=/usr/bin/git
Alain Reguera Delgado 8f60cb
                ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            'subversion' )
Alain Reguera Delgado 8f60cb
                COMMAND=/usr/bin/svn
Alain Reguera Delgado 8f60cb
                ;;
Alain Reguera Delgado 8f60cb
        esac
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    else
Alain Reguera Delgado 8f60cb
        cli_printMessage "${PACKAGE} `gettext "isn't supported as version control system."`" --as-error-line
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify whether the related package is installed or not.
Alain Reguera Delgado 8f60cb
    cli_checkFiles ${PACKAGE} --is-installed
Alain Reguera Delgado 8f60cb
    
Alain Reguera Delgado 8f60cb
    # Interpret arguments and options passed through command-line.
Alain Reguera Delgado 8f60cb
    vcs_getOptions
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Initialize function specific export id.
Alain Reguera Delgado 8f60cb
    local EXPORTID="${CLI_FUNCDIRNAM}/$(cli_getRepoName ${PACKAGE} -d)/$(cli_getRepoName ${PACKAGE} -f)"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Export specific functionalities to the script environment.
Alain Reguera Delgado 8f60cb
    cli_exportFunctions "${EXPORTID}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Execute version control.
Alain Reguera Delgado 8f60cb
    ${PACKAGE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Unset specific functionalities from the script environment.
Alain Reguera Delgado 8f60cb
    cli_unsetFunctions "${EXPORTID}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}