|
|
4debce |
#!/bin/bash
|
|
|
4debce |
#
|
|
|
4debce |
# svn_commitRepoChanges.sh -- This function realizes a subversion
|
|
|
4debce |
# commit command agains the workgin copy in order to send local
|
|
|
4debce |
# changes up to central repository.
|
|
|
4debce |
#
|
|
|
4debce |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
4debce |
#
|
|
|
4debce |
# This program is free software; you can redistribute it and/or modify
|
|
|
4debce |
# it under the terms of the GNU General Public License as published by
|
|
|
4debce |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
4debce |
# your option) any later version.
|
|
|
4debce |
#
|
|
|
4debce |
# This program is distributed in the hope that it will be useful, but
|
|
|
4debce |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4debce |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4debce |
# General Public License for more details.
|
|
|
4debce |
#
|
|
|
4debce |
# You should have received a copy of the GNU General Public License
|
|
|
4debce |
# along with this program; if not, write to the Free Software
|
|
|
4debce |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
4debce |
#
|
|
|
4debce |
# ----------------------------------------------------------------------
|
|
|
4debce |
# $Id$
|
|
|
4debce |
# ----------------------------------------------------------------------
|
|
|
4debce |
|
|
|
4debce |
function svn_commitRepoChanges {
|
|
|
4debce |
|
|
|
4debce |
local -a FILES
|
|
|
4debce |
local -a INFO
|
|
|
4debce |
local -a FILESNUM
|
|
|
4debce |
local COUNT=0
|
|
|
4debce |
local STATUSOUT=''
|
|
|
4debce |
local PREDICATE=''
|
|
|
4debce |
local CHNGTOTAL=0
|
|
|
4debce |
|
|
|
4debce |
# Print action message.
|
|
|
4debce |
cli_printMessage "`gettext "Checking changes in the working copy"`" --as-banner-line
|
|
|
4debce |
|
|
|
4debce |
# Build list of files that have received changes in its versioned
|
|
|
4debce |
# status. Be sure to keep output files off from this list.
|
|
|
4debce |
# Remember, output files are not versioned inside the working
|
|
|
4debce |
# copy, so they are not considered for evaluation here. But take
|
|
|
4debce |
# care, sometimes output files are in the same format of source
|
|
|
4debce |
# files, so we need to differentiate them using their locations.
|
|
|
4debce |
|
|
|
0d9c14 |
# Process location based on its path information.
|
|
|
0d9c14 |
if [[ $ACTIONVAL =~ 'trunk/Documentation/Manuals/Texinfo)' ]];then
|
|
|
0d9c14 |
STATUSOUT="$(${SVN} status ${ACTIONVAL} | egrep -v '(pdf|txt|xhtml|xml|docbook|bz2)$')\n$STATUSOUT"
|
|
|
0d9c14 |
elif [[ $ACTIONVAL =~ 'trunk/Manuals/Documentation/Manuals/Docbook' ]];then
|
|
|
0d9c14 |
STATUSOUT="$(${SVN} status ${ACTIONVAL} | egrep -v '(pdf|txt|xhtml)$')\n$STATUSOUT"
|
|
|
0d9c14 |
elif [[ $ACTIONVAL =~ 'trunk/Identity' ]];then
|
|
|
0d9c14 |
STATUSOUT="$(${SVN} status ${ACTIONVAL} | egrep -v '(pdf|png|jpg|rc|xpm|xbm|tif|ppm|pnm|gz|lss|log)$')\n$STATUSOUT"
|
|
|
0d9c14 |
else
|
|
|
0d9c14 |
STATUSOUT="$(${SVN} status ${ACTIONVAL})\n$STATUSOUT"
|
|
|
0d9c14 |
fi
|
|
|
4debce |
|
|
|
4debce |
# Sanitate status output. Expand new lines, remove leading spaces
|
|
|
4debce |
# and empty lines.
|
|
|
4debce |
STATUSOUT=$(echo -e "$STATUSOUT" | sed -r 's!^[[:space:]]*!!' | egrep -v '^[[:space:]]*$')
|
|
|
4debce |
|
|
|
4debce |
# Define path fo files considered recent modifications from
|
|
|
4debce |
# working copy up to central repository.
|
|
|
0d9c14 |
FILES[0]=$(echo "$STATUSOUT" | egrep "^M.+$(cli_getRepoTLDir "${ACTIONVAL}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${ACTIONVAL}").+)$,\1,")
|
|
|
0d9c14 |
FILES[1]=$(echo "$STATUSOUT" | egrep "^\?.+$(cli_getRepoTLDir "${ACTIONVAL}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${ACTIONVAL}").+)$,\1,")
|
|
|
0d9c14 |
FILES[2]=$(echo "$STATUSOUT" | egrep "^D.+$(cli_getRepoTLDir "${ACTIONVAL}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${ACTIONVAL}").+)$,\1,")
|
|
|
0d9c14 |
FILES[3]=$(echo "$STATUSOUT" | egrep "^A.+$(cli_getRepoTLDir "${ACTIONVAL}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${ACTIONVAL}").+)$,\1,")
|
|
|
4debce |
|
|
|
4debce |
# Define description of files considered recent modifications from
|
|
|
4debce |
# working copy up to central repository.
|
|
|
4debce |
INFO[0]="`gettext "Modified"`"
|
|
|
4debce |
INFO[1]="`gettext "Unversioned"`"
|
|
|
4debce |
INFO[2]="`gettext "Deleted"`"
|
|
|
4debce |
INFO[3]="`gettext "Added"`"
|
|
|
4debce |
|
|
|
4debce |
while [[ $COUNT -ne ${#FILES[*]} ]];do
|
|
|
4debce |
|
|
|
4debce |
# Define total number of files. Avoid counting empty line.
|
|
|
4debce |
if [[ "${FILES[$COUNT]}" == '' ]];then
|
|
|
4debce |
FILESNUM[$COUNT]=0
|
|
|
4debce |
else
|
|
|
4debce |
FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l)
|
|
|
4debce |
fi
|
|
|
4debce |
|
|
|
4debce |
# Calculate total amount of changes.
|
|
|
4debce |
CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]}))
|
|
|
4debce |
|
|
|
4debce |
# Build report predicate. Use report predicate to show any
|
|
|
4debce |
# information specific to the number of files found. For
|
|
|
4debce |
# example, you can use this section to show warning messages,
|
|
|
4debce |
# notes, and so on. By default we use the word `file' or
|
|
|
4debce |
# `files' at ngettext's consideration followed by change
|
|
|
4debce |
# direction.
|
|
|
4debce |
PREDICATE[$COUNT]=`ngettext "file in the working copy" \
|
|
|
4debce |
"files in the working copy" $((${FILESNUM[$COUNT]} + 1))`
|
|
|
4debce |
|
|
|
4debce |
# Output report line.
|
|
|
4debce |
cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}"
|
|
|
4debce |
|
|
|
4debce |
# Increase counter.
|
|
|
4debce |
COUNT=$(($COUNT + 1))
|
|
|
4debce |
|
|
|
4debce |
done
|
|
|
4debce |
|
|
|
4debce |
# Check total amount of changes and, if any, check differences and
|
|
|
4debce |
# commit them up to central repository.
|
|
|
4debce |
if [[ $CHNGTOTAL -gt 0 ]];then
|
|
|
4debce |
|
|
|
4debce |
# Outout separator line.
|
|
|
4debce |
cli_printMessage '-' --as-separator-line
|
|
|
4debce |
|
|
|
4debce |
# In the very specific case unversioned files, we need to add
|
|
|
4debce |
# them to the repository first, in order to make them
|
|
|
4debce |
# available for subversion commands (e.g., `copy') Otherwise,
|
|
|
4debce |
# if no unversioned file is found, go ahead with change
|
|
|
4debce |
# differences and committing. Notice that if there is mix of
|
|
|
4debce |
# changes (e.g., aditions and modifications), addition take
|
|
|
4debce |
# preference and no other change is considered. In order
|
|
|
4debce |
# for other changes to be considered, be sure no adition is
|
|
|
4debce |
# present, or that they have already happened.
|
|
|
4debce |
if [[ ${FILESNUM[1]} -gt 0 ]];then
|
|
|
4debce |
|
|
|
4debce |
cli_printMessage "`ngettext "The following file is unversioned" \
|
|
|
4debce |
"The following files are unversioned" ${FILESNUM[1]}`:"
|
|
|
4debce |
for FILE in ${FILES[1]};do
|
|
|
4debce |
cli_printMessage "$FILE" --as-response-line
|
|
|
4debce |
done
|
|
|
4debce |
cli_printMessage "`ngettext "Do you want to add it now?" \
|
|
|
4debce |
"Do you want to add them now?" ${FILESNUM[1]}`" --as-yesornorequest-line
|
|
|
0d9c14 |
${SVN} add ${FILES[1]} --quiet
|
|
|
4debce |
|
|
|
4debce |
else
|
|
|
4debce |
|
|
|
4debce |
# Verify changes on locations.
|
|
|
4debce |
cli_printMessage "`gettext "Do you want to see changes now?"`" --as-yesornorequest-line
|
|
|
0d9c14 |
${SVN} diff $ACTIONVAL | less
|
|
|
4debce |
|
|
|
4debce |
# Commit changes on locations.
|
|
|
4debce |
cli_printMessage "`gettext "Do you want to commit changes now?"`" --as-yesornorequest-line
|
|
|
0d9c14 |
${SVN} commit $ACTIONVAL
|
|
|
4debce |
|
|
|
4debce |
fi
|
|
|
4debce |
|
|
|
4debce |
fi
|
|
|
4debce |
}
|