Blame Functions/cli_getRepoStatus.sh

c8faf4
#!/bin/bash
c8faf4
#
c8faf4
# cli_getRepoStatus.sh -- This function requests the working copy
5f7975
# using the svn status command and returns the first character in the
5f7975
# output line, as described in svn help status, for the LOCATION
68c0cf
# specified. Use this function to perform verifications based a
5f7975
# repository LOCATION status. 
c8faf4
#
a9faca
# Copyright (C) 2009-2011 Alain Reguera Delgado
c8faf4
# 
c8faf4
# This program is free software; you can redistribute it and/or
c8faf4
# modify it under the terms of the GNU General Public License as
c8faf4
# published by the Free Software Foundation; either version 2 of the
c8faf4
# License, or (at your option) any later version.
c8faf4
# 
c8faf4
# This program is distributed in the hope that it will be useful, but
c8faf4
# WITHOUT ANY WARRANTY; without even the implied warranty of
c8faf4
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c8faf4
# General Public License for more details.
c8faf4
#
c8faf4
# You should have received a copy of the GNU General Public License
c8faf4
# along with this program; if not, write to the Free Software
c8faf4
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
c8faf4
# USA.
c8faf4
# 
c8faf4
# ----------------------------------------------------------------------
c8faf4
# $Id$
c8faf4
# ----------------------------------------------------------------------
c8faf4
c8faf4
function cli_getRepoStatus {
c8faf4
c01d0e
    local LOCATION="$1"
c8faf4
    local STATUS=''
c8faf4
2120de
    # Define regular expression pattern to retrive first column,
2120de
    # returned by subversion status command. This column is one
2120de
    # character column as describes `svn help status' command.
25b88b
    local PATTERN='^( |A|C|D|I|M|R|X|\?|!|~).+$'
2120de
c8faf4
    # Verify the file used as source to retrive its status
c8faf4
    # information. We only use regular files or directories inside the
c8faf4
    # working copy.
c01d0e
    cli_checkFiles "$LOCATION" 'fd'
b8ce89
    cli_checkFiles "$LOCATION" 'isInWorkingCopy'
c8faf4
c8faf4
    # Use subversion `status' command to retrive the first character
25b88b
    # in the output. Discard standard error output.
25b88b
    STATUS="$(svn status "$LOCATION" | sed -r "s/${PATTERN}/\1/" 2>/dev/null)"
c8faf4
c8faf4
    # Outout status information.
c8faf4
    echo -n "$STATUS"
c8faf4
c8faf4
}