|
|
d627b6 |
#!/bin/bash
|
|
|
d627b6 |
#
|
|
|
3071b7 |
# cli_commitRepoChanges.sh -- This function realizes a subversion
|
|
|
3071b7 |
# commit command agains the workgin copy in order to send local
|
|
|
3071b7 |
# changes up to central repository.
|
|
|
d627b6 |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# 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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
d627b6 |
# ----------------------------------------------------------------------
|
|
|
d627b6 |
# $Id$
|
|
|
d627b6 |
# ----------------------------------------------------------------------
|
|
|
d627b6 |
|
|
|
d627b6 |
function cli_commitRepoChanges {
|
|
|
d627b6 |
|
|
|
49237e |
# Verify `--dont-commit-changes' option.
|
|
|
49237e |
if [[ $FLAG_DONT_COMMIT_CHANGES == 'true' ]];then
|
|
|
af4cfe |
return
|
|
|
af4cfe |
fi
|
|
|
af4cfe |
|
|
|
4e4549 |
local -a FILES
|
|
|
4e4549 |
local -a INFO
|
|
|
4e4549 |
local -a FILESNUM
|
|
|
d627b6 |
local COUNT=0
|
|
|
3071b7 |
local STATUSOUT=''
|
|
|
4e4549 |
local PREDICATE=''
|
|
|
b3ea32 |
local CHNGTOTAL=0
|
|
|
55612a |
local LOCATIONS=''
|
|
|
7a4fcb |
local LOCATION=''
|
|
|
d627b6 |
|
|
|
3071b7 |
# Define source location the subversion status action will take
|
|
|
3071b7 |
# place on. If arguments are provided use them as srouce location.
|
|
|
3071b7 |
# Otherwise use action value as default source location.
|
|
|
55612a |
if [[ "$@" != '' ]];then
|
|
|
55612a |
LOCATIONS="$@"
|
|
|
ae2995 |
else
|
|
|
55612a |
LOCATIONS="$ACTIONVAL"
|
|
|
640f58 |
fi
|
|
|
640f58 |
|
|
|
55612a |
# Check working copy.
|
|
|
dfb60b |
cli_printMessage "`gettext "Checking changes in the working copy"`" --as-banner-line
|
|
|
55612a |
STATUSOUT=$(svn status ${LOCATIONS})
|
|
|
ba0dfe |
|
|
|
58a639 |
# Define path fo files considered recent modifications from
|
|
|
58a639 |
# working copy up to central repository.
|
|
|
3071b7 |
FILES[0]=$(echo "$STATUSOUT" | egrep "^M.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
FILES[1]=$(echo "$STATUSOUT" | egrep "^\?.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
FILES[2]=$(echo "$STATUSOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
FILES[3]=$(echo "$STATUSOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
58a639 |
|
|
|
58a639 |
# Define description of files considered recent modifications from
|
|
|
58a639 |
# working copy up to central repository.
|
|
|
3071b7 |
INFO[0]="`gettext "Modified"`"
|
|
|
3071b7 |
INFO[1]="`gettext "Unversioned"`"
|
|
|
3071b7 |
INFO[2]="`gettext "Deleted"`"
|
|
|
3071b7 |
INFO[3]="`gettext "Added"`"
|
|
|
d627b6 |
|
|
|
4e4549 |
while [[ $COUNT -ne ${#FILES[*]} ]];do
|
|
|
d627b6 |
|
|
|
3071b7 |
# Define total number of files. Avoid counting empty line.
|
|
|
58a639 |
if [[ "${FILES[$COUNT]}" == '' ]];then
|
|
|
4e4549 |
FILESNUM[$COUNT]=0
|
|
|
4e4549 |
else
|
|
|
4e4549 |
FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l)
|
|
|
4e4549 |
fi
|
|
|
4e4549 |
|
|
|
b3ea32 |
# Calculate total amount of changes.
|
|
|
b3ea32 |
CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]}))
|
|
|
b3ea32 |
|
|
|
4e4549 |
# Build report predicate. Use report predicate to show any
|
|
|
4e4549 |
# information specific to the number of files found. For
|
|
|
4e4549 |
# example, you can use this section to show warning messages,
|
|
|
58a639 |
# notes, and so on. By default we use the word `file' or
|
|
|
58a639 |
# `files' at ngettext's consideration followed by change
|
|
|
58a639 |
# direction.
|
|
|
1ff118 |
PREDICATE[$COUNT]=`ngettext "file in the working copy" \
|
|
|
1ff118 |
"files in the repository" $((${FILESNUM[$COUNT]} + 1))`
|
|
|
58a639 |
|
|
|
4e4549 |
# Output report line.
|
|
|
dfb60b |
cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}"
|
|
|
4e4549 |
|
|
|
4e4549 |
# Increase counter.
|
|
|
4e4549 |
COUNT=$(($COUNT + 1))
|
|
|
4e4549 |
|
|
|
4e4549 |
done
|
|
|
4e4549 |
|
|
|
3071b7 |
# Check total amount of changes and, if any, check differences and
|
|
|
3071b7 |
# commit them up to central repository.
|
|
|
3071b7 |
if [[ $CHNGTOTAL -gt 0 ]];then
|
|
|
d627b6 |
|
|
|
3036ea |
# Outout separator line.
|
|
|
dfb60b |
cli_printMessage '-' --as-separator-line
|
|
|
3036ea |
|
|
|
ed8ada |
# In the very specific case unversioned files, we need to add
|
|
|
ed8ada |
# them to the repository first, in order to make them
|
|
|
ed8ada |
# available for subversion commands (e.g., `copy', etc.)
|
|
|
ed8ada |
# Otherwise, if no unversioned file is found, go ahead with
|
|
|
ed8ada |
# change differences and committing. Notice that if there is
|
|
|
ed8ada |
# mix of changes (e.g., aditions and modifications), addition
|
|
|
ed8ada |
# take preference and no other change is considered. In order
|
|
|
ed8ada |
# for other changes to be considered, be sure no adition is
|
|
|
ed8ada |
# present, or that they have already happened.
|
|
|
ed8ada |
if [[ ${FILESNUM[1]} -gt 0 ]];then
|
|
|
ed8ada |
|
|
|
ed8ada |
cli_printMessage "`ngettext "The following file is unversioned" \
|
|
|
ed8ada |
"The following files are unversioned" ${FILESNUM[1]}`:"
|
|
|
ed8ada |
for FILE in ${FILES[1]};do
|
|
|
ed8ada |
cli_printMessage "$FILE" --as-response-line
|
|
|
ed8ada |
done
|
|
|
ed8ada |
cli_printMessage "`ngettext "Do you want to add it now?" \
|
|
|
ed8ada |
"Do you want to add them now?" ${FILESNUM[1]}`" --as-yesornorequest-line
|
|
|
ed8ada |
svn add ${FILES[1]} --quiet
|
|
|
d627b6 |
|
|
|
ed8ada |
else
|
|
|
ed8ada |
|
|
|
ed8ada |
# Verify changes on locations.
|
|
|
ed8ada |
cli_printMessage "`gettext "Do you want to see changes now?"`" --as-yesornorequest-line
|
|
|
ed8ada |
svn diff $LOCATIONS | less
|
|
|
ed8ada |
|
|
|
ed8ada |
# Commit changes on locations.
|
|
|
ed8ada |
cli_printMessage "`gettext "Do you want to commit changes now?"`" --as-yesornorequest-line
|
|
|
ed8ada |
svn commit $LOCATIONS
|
|
|
ed8ada |
|
|
|
ed8ada |
fi
|
|
|
4e4549 |
|
|
|
d627b6 |
fi
|
|
|
d627b6 |
|
|
|
d627b6 |
}
|