-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-info
executable file
·53 lines (43 loc) · 1.05 KB
/
git-info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
#
# Copyright (c) 2009 Daniel Gryniewicz
#
# Do the equivalent of svn info
# Set usage output
DESCRIPTION="Brief information about a git repo"
USAGE="[-h |--help]"
LONGUSAGE="Get info about a git repository
\t-h, --help\n\t\tPrint this help message"
# Standard functions
GTWS_LOC=$(readlink -f $(dirname "$0"))
source ${GTWS_LOC}/gtws.sh
# Script name
ME=$(basename $0)
# Parse arguments
ARGS=`getopt -o h --long help -n "${ME}" -- "$@"`
if [ $? != 0 ] ; then
usage
fi
eval set -- "$ARGS"
while true ; do
case "$1" in
-h|--help) usage; shift ;;
--) shift ; break ;;
* ) usage "Invalid argument $1";;
esac
done
# Remaining arguments are in $1, $2, etc. as normal
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
LONG_USAGE="${LONGUSAGE}"
# Source the git environment
source "$(git --exec-path)/git-sh-setup"
BRANCH=$(git-branch | grep '\*' | awk '{print $2}')
echo "BRANCH: ${BRANCH}"
if git-issvn > /dev/null 2>&1; then
SVN=$(git svn info 2>/dev/null | grep URL)
echo "SVN ${SVN}"
else
REMOTE=$(git-config --get remote.origin.url)
echo "URL: ${REMOTE}"
fi