Blame Scripts/Bash/Functions/Vcs/Git/git_copyRepoFile.sh

123ee8
#!/bin/bash
123ee8
#
123ee8
# git_copyRepoFile.sh -- This function standardizes the way files
123ee8
# (including directories) are duplicated inside the working copy. This
123ee8
# function is an interface for git's `copy' command.
123ee8
#
e6bbbf
# Copyright (C) 2009-2013 The CentOS Project
123ee8
#
123ee8
# This program is free software; you can redistribute it and/or modify
123ee8
# it under the terms of the GNU General Public License as published by
123ee8
# the Free Software Foundation; either version 2 of the License, or (at
123ee8
# your option) any later version.
123ee8
#
123ee8
# This program is distributed in the hope that it will be useful, but
123ee8
# WITHOUT ANY WARRANTY; without even the implied warranty of
123ee8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
123ee8
# General Public License for more details.
123ee8
#
123ee8
# You should have received a copy of the GNU General Public License
123ee8
# along with this program; if not, write to the Free Software
123ee8
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
123ee8
#
123ee8
# ----------------------------------------------------------------------
123ee8
# $Id$
123ee8
# ----------------------------------------------------------------------
123ee8
123ee8
function git_copyRepoFile {
123ee8
123ee8
    local SOURCE=$(cli_checkRepoDirSource ${1})
123ee8
    local TARGET=$(cli_checkRepoDirSource ${2})
123ee8
123ee8
    # Verify source location absolute path. It should point to
123ee8
    # existent files or directories. They don't need to be under
123ee8
    # version control.
de6ddf
    cli_checkFiles ${SOURCE} -e
123ee8
123ee8
    # Print action reference.
123ee8
    if [[ -f ${SOURCE} ]];then
123ee8
        cli_printMessage "${TARGET}/$(basename ${SOURCE})" --as-creating-line
123ee8
    else
123ee8
        cli_printMessage "${TARGET}" --as-creating-line
123ee8
    fi
123ee8
123ee8
    # Copy source location to its target using version control. I
123ee8
    # didn't find a copy command for Git. If you know a better way to
123ee8
    # track a copy action through Git, set it here.
123ee8
    /bin/cp ${SOURCE} ${TARGET}
123ee8
    if [[ $? -eq 0 ]];then
123ee8
        ${COMMAND} add ${TARGET}
123ee8
    fi
123ee8
 
123ee8
}