|
|
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 |
|
|
|
dcd347 |
|
|
|
dcd347 |
|
|
|
fa95b1 |
#
|
|
|
74a058 |
|
|
|
74a058 |
|
|
|
d627b6 |
|
|
|
d627b6 |
# General Public License for more details.
|
|
|
d627b6 |
#
|
|
|
d627b6 |
|
|
|
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 |
|
|
|
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 |
|
|
|
3071b7 |
|
|
|
3071b7 |
|
|
|
55612a |
if [[ "$@" != '' ]];then
|
|
|
55612a |
LOCATIONS="$@"
|
|
|
ae2995 |
else
|
|
|
55612a |
LOCATIONS="$ACTIONVAL"
|
|
|
640f58 |
fi
|
|
|
640f58 |
|
|
|
55612a |
|
|
|
dfb60b |
cli_printMessage "`gettext "Checking changes in the working copy"`" --as-banner-line
|
|
|
55612a |
STATUSOUT=$(svn status ${LOCATIONS})
|
|
|
ba0dfe |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
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 |
|
|
|
58a639 |
|
|
|
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 |
|
|
|
b3ea32 |
CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]}))
|
|
|
b3ea32 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
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 |
|
|
|
4e4549 |
COUNT=$(($COUNT + 1))
|
|
|
4e4549 |
|
|
|
4e4549 |
done
|
|
|
4e4549 |
|
|
|
3071b7 |
# Check total amount of changes and, if any, check differences and
|
|
|
3071b7 |
|
|
|
3071b7 |
if [[ $CHNGTOTAL -gt 0 ]];then
|
|
|
d627b6 |
|
|
|
3036ea |
# Outout separator line.
|
|
|
dfb60b |
cli_printMessage '-' --as-separator-line
|
|
|
3036ea |
|
|
|
ed8ada |
|
|
|
ed8ada |
|
|
|
ed8ada |
|
|
|
ed8ada |
# Otherwise, if no unversioned file is found, go ahead with
|
|
|
ed8ada |
# change differences and committing. Notice that if there is
|
|
|
ed8ada |
|
|
|
ed8ada |
|
|
|
ed8ada |
|
|
|
ed8ada |
|
|
|
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]}`"
|
|
|
ed8ada |
svn add ${FILES[1]} --quiet
|
|
|
d627b6 |
|
|
|
ed8ada |
else
|
|
|
ed8ada |
|
|
|
ed8ada |
|
|
|
ed8ada |
cli_printMessage "`gettext "Do you want to see changes now?"`"
|
|
|
ed8ada |
svn diff $LOCATIONS | less
|
|
|
ed8ada |
|
|
|
ed8ada |
|
|
|
ed8ada |
cli_printMessage "`gettext "Do you want to commit changes now?"`"
|
|
|
ed8ada |
svn commit $LOCATIONS
|
|
|
ed8ada |
|
|
|
ed8ada |
fi
|
|
|
4e4549 |
|
|
|
d627b6 |
fi
|
|
|
d627b6 |
|
|
|
d627b6 |
}
|