Temporary Hardcoded Ubuntu repo
[fuel.git] / build / repo_info.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 usage() {
13   cat <<EOF
14 Usage: `basename $0` [-r] <path>
15
16  -r
17     Recursively list all repos found starting at <path>
18  -h
19     Display help text
20 EOF
21 }
22
23 repoinfo() {
24     repotop=$(git -C $1 rev-parse --show-toplevel)
25     origin=$(git -C $repotop config --get remote.origin.url)
26     sha1=$(git -C $repotop rev-parse HEAD)
27     echo "$origin: $sha1"
28 }
29
30
31 if [ $# -eq 2 ]; then
32     case $1 in
33         -r)
34             RECURSE=1
35             shift
36             ;;
37         -h)
38             usage
39             exit 0
40             ;;
41         *)
42             echo "Error, argument $1 not known" >&2
43             usage
44             exit 1
45     esac
46 fi
47
48 if [ $# -gt 1 ]; then
49     echo "Error, too many arguments" >&2
50     usage
51     exit 1
52 fi
53
54 abspath=$(readlink -f $1)
55
56 if [ -n "$RECURSE" ]; then
57     for dir in $(find $abspath -type d -name .git)
58     do
59         repoinfo $(readlink -f $dir/..)
60     done
61 else
62     repoinfo $abspath
63 fi