Blame Scripts/Bash/Functions/Svn/svn_getRepoStatus.sh

e142db
#!/bin/bash
e142db
#
e142db
# svn_getRepoStatus.sh -- This function requests the working copy
e142db
# using the svn status command and returns the first character in the
e142db
# output line, as described in svn help status, for the LOCATION
e142db
# specified. Use this function to perform verifications based a
e142db
# repository LOCATION status. 
e142db
#
e142db
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
e142db
#
e142db
# This program is free software; you can redistribute it and/or modify
e142db
# it under the terms of the GNU General Public License as published by
e142db
# the Free Software Foundation; either version 2 of the License, or (at
e142db
# your option) any later version.
e142db
#
e142db
# This program is distributed in the hope that it will be useful, but
e142db
# WITHOUT ANY WARRANTY; without even the implied warranty of
e142db
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e142db
# General Public License for more details.
e142db
#
e142db
# You should have received a copy of the GNU General Public License
e142db
# along with this program; if not, write to the Free Software
e142db
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e142db
#
e142db
# ----------------------------------------------------------------------
e142db
# $Id$
e142db
# ----------------------------------------------------------------------
e142db
e142db
function svn_getRepoStatus {
e142db
8e9eff
    local LOCATION=$(cli_checkRepoDirSource "$1")
e142db
f72607
    # Verify source location absolute path. It should point either to
f72607
    # existent files or directories both under version control inside
f72607
    # the working copy.  Otherwise, if it doesn't point to an existent
f72607
    # file under version control, finish the script execution with an
f72607
    # error message.
f72607
    cli_checkFiles ${LOCATION} -e --is-versioned
f72607
f72607
    # Define regular expression pattern to retrieve first column,
e142db
    # returned by subversion status command. This column is one
e142db
    # character column as describes `svn help status' command.
e142db
    local PATTERN='^( |A|C|D|I|M|R|X|!|~).+$'
e142db
e142db
    # Output specific state of location using subversion `status'
e142db
    # command.
e142db
    ${SVN} status "$LOCATION" -N --quiet | sed -r "s/${PATTERN}/\1/"
e142db
e142db
}