Blame Automation/centos-art.sh-mods/Vcs/Git/git.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# git.sh -- This function standardizes Git tasks inside the
Alain Reguera Delgado 8f60cb
# 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 git {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Redefine positional parameters using ARGUMENTS. At this point,
Alain Reguera Delgado 8f60cb
    # option arguments have been removed from ARGUMENTS variable and
Alain Reguera Delgado 8f60cb
    # only non-option arguments remain in it. 
Alain Reguera Delgado 8f60cb
    eval set -- "$ARGUMENTS"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Don't realize action value verification here. There are actions
Alain Reguera Delgado 8f60cb
    # like `copy' and `rename' that require two arguments from which
Alain Reguera Delgado 8f60cb
    # the last one doesn't exist at the moment of executing the
Alain Reguera Delgado 8f60cb
    # command. This will provoke the second action value verification
Alain Reguera Delgado 8f60cb
    # to fail when indeed is should not. Thus, go to action names
Alain Reguera Delgado 8f60cb
    # processing directly.
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # All git actions will be performed against the working copy.
Alain Reguera Delgado 8f60cb
    # Otherwise, errors like `fatal: Not a git repository (or any of
Alain Reguera Delgado 8f60cb
    # the parent directories): .git' or `Unable to determine absolute
Alain Reguera Delgado 8f60cb
    # path of git directory' might occur. So, move from whenever you
Alain Reguera Delgado 8f60cb
    # be right now up to the git working copy.
Alain Reguera Delgado 8f60cb
    pushd ${TCAR_WORKDIR} > /dev/null
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Execute action names. This is required in order to realize
Alain Reguera Delgado 8f60cb
    # actions like copy and rename which need two values as argument.
Alain Reguera Delgado 8f60cb
    # Otherwise, it wouldn't be possible to execute them because
Alain Reguera Delgado 8f60cb
    # action values would be processed one a time. Thus, lets work
Alain Reguera Delgado 8f60cb
    # with `$@' instead.
Alain Reguera Delgado 8f60cb
    for ACTIONNAM in $ACTIONNAMS;do
Alain Reguera Delgado 8f60cb
        $ACTIONNAM "$@"
Alain Reguera Delgado 8f60cb
    done
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Return to the place you were initially. 
Alain Reguera Delgado 8f60cb
    popd > /dev/null
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}