Blame Scripts/Bash/Functions/cli_getRepoStatus.sh

c8faf4
#!/bin/bash
c8faf4
#
c8faf4
# cli_getRepoStatus.sh -- This function requests the working copy
c8faf4
# using the `svn status' command to return the first character on each
c8faf4
# output line, as described in `svn help status`. Use this function to
c8faf4
# know which status, the first argument passed to this function, has.
c8faf4
#
c8faf4
# Copyright (C) 2009, 2010 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
c8faf4
    local FILE="$1"
c8faf4
    local STATUS=''
c8faf4
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.
c8faf4
    cli_checkFiles "$FILE" 'fd'
c8faf4
c8faf4
    # Use subversion `status' command to retrive the first character
c8faf4
    # in the output.
c8faf4
    STATUS=$(svn status "$FILE" --quiet | sed -r 's/^( |A|C|D|I|M|R|X|\?|!|~]).+/\1/' )
c8faf4
c8faf4
    # Outout status information.
c8faf4
    echo -n "$STATUS"
c8faf4
c8faf4
}