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