Blame Scripts/Bash/Functions/cli_commitRepoChanges.sh

d627b6
#!/bin/bash
d627b6
#
d627b6
# cli_commitRepoChanges.sh -- This function looks for changes inside
d627b6
# absolute path passed as option value and ask you to commit them up
7d5407
# to central repository. Use this function at the end of whatever
7d5407
# function you make a change to repository files. It is better to
7d5407
# commit small changes than long ones.
d627b6
#
d627b6
# Copyright (C) 2009-2010 Alain Reguera Delgado
d627b6
# 
d627b6
# This program is free software; you can redistribute it and/or modify
d627b6
# it under the terms of the GNU General Public License as published by
d627b6
# the Free Software Foundation; either version 2 of the License, or
d627b6
# (at your option) any later version.
d627b6
# 
d627b6
# This program is distributed in the hope that it will be useful, but
d627b6
# WITHOUT ANY WARRANTY; without even the implied warranty of
d627b6
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d627b6
# General Public License for more details.
d627b6
#
d627b6
# You should have received a copy of the GNU General Public License
d627b6
# along with this program; if not, write to the Free Software
d627b6
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
d627b6
# USA.
d627b6
# 
d627b6
# ----------------------------------------------------------------------
d627b6
# $Id$
d627b6
# ----------------------------------------------------------------------
d627b6
d627b6
function cli_commitRepoChanges {
d627b6
d627b6
    local FILES=''
d627b6
    local COUNT=0
d627b6
d627b6
    # Define list of changed files.
d627b6
    FILES=$(svn status $OPTIONVAL | egrep '^M' | cut -d' ' -f7)
d627b6
d627b6
    # Define number of changed files.
3d2a24
    COUNT=$(echo "$FILES" | wc -l)
d627b6
d627b6
    # Check list of changed files and ask the user to commit changes
d627b6
    # if there is any.
d627b6
    if [[ $COUNT -gt 0 ]];then
d627b6
d627b6
        cli_printMessage "`ngettext "The following file was changed" \
d627b6
            "The following files were changed" $COUNT`:"
d627b6
d627b6
        # Show list of affected entries.
d627b6
        for FILE in $FILES;do
d627b6
            cli_printMessage "$FILE" "AsResponseLine"
d627b6
        done
d627b6
d627b6
        # Verify changes.
d627b6
        cli_printMessage "`gettext "Do you want to see these changes now?"`" "AsYesOrNoRequestLine"
d627b6
        svn diff $FILES | less
d627b6
d627b6
        # Commit changes.
d627b6
        cli_printMessage "`gettext "Do you want commit these changes now?"`" "AsYesOrNoRequestLine"
d627b6
        svn commit $FILES
d627b6
    fi
d627b6
d627b6
}