c8faf4 Add cli_getRepoStatus.sh:

Authored and Committed by areguera 14 years ago
    Add cli_getRepoStatus.sh:
    
        - This function requests the working copy using the `svn status'
          command to return the first character on each output line, as
          described in `svn help status`. Use this function to know which
          status, the first argument passed to this function, has.
    
    
        
Scripts/Bash/Functions/cli_getRepoStatus.sh ADDED
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ #
3
+ # cli_getRepoStatus.sh -- This function requests the working copy
4
+ # using the `svn status' command to return the first character on each
5
+ # output line, as described in `svn help status`. Use this function to
6
+ # know which status, the first argument passed to this function, has.
7
+ #
8
+ # Copyright (C) 2009, 2010 Alain Reguera Delgado
9
+ #
10
+ # This program is free software; you can redistribute it and/or
11
+ # modify it under the terms of the GNU General Public License as
12
+ # published by the Free Software Foundation; either version 2 of the
13
+ # License, or (at your option) any later version.
14
+ #
15
+ # This program is distributed in the hope that it will be useful, but
16
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ # General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU General Public License
21
+ # along with this program; if not, write to the Free Software
22
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23
+ # USA.
24
+ #
25
+ # ----------------------------------------------------------------------
26
+ # $Id$
27
+ # ----------------------------------------------------------------------
28
+
29
+ function cli_getRepoStatus {
30
+
31
+ local FILE="$1"
32
+ local STATUS=''
33
+
34
+ # Verify the file used as source to retrive its status
35
+ # information. We only use regular files or directories inside the
36
+ # working copy.
37
+ cli_checkFiles "$FILE" 'fd'
38
+
39
+ # Use subversion `status' command to retrive the first character
40
+ # in the output.
41
+ STATUS=$(svn status "$FILE" --quiet | sed -r 's/^( |A|C|D|I|M|R|X|\?|!|~]).+/\1/' )
42
+
43
+ # Outout status information.
44
+ echo -n "$STATUS"
45
+
46
+ }