xref: /minix3/external/bsd/llvm/dist/llvm/utils/GetRepositoryPath (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc#!/bin/sh
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambucusage() {
4*f4a2713aSLionel Sambuc  echo "usage: $0 <source root>"
5*f4a2713aSLionel Sambuc  echo "  Prints the source control repository path of the given source"
6*f4a2713aSLionel Sambuc  echo "  directory, the exact format of the revision string depends on the"
7*f4a2713aSLionel Sambuc  echo "  source control system. If the source control system isn't known,"
8*f4a2713aSLionel Sambuc  echo "  the output is empty and the exit code is 1."
9*f4a2713aSLionel Sambuc  exit 1
10*f4a2713aSLionel Sambuc}
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambucif [ $# != 1 ] || [ ! -d $1 ]; then
13*f4a2713aSLionel Sambuc  usage;
14*f4a2713aSLionel Sambucfi
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuccd $1
17*f4a2713aSLionel Sambucif [ -d .svn ]; then
18*f4a2713aSLionel Sambuc  svn info | grep '^URL:' | cut -d: -f2-
19*f4a2713aSLionel Sambucelif [ -f .git/svn/.metadata ]; then
20*f4a2713aSLionel Sambuc  git svn info | grep 'URL:' | cut -d: -f2-
21*f4a2713aSLionel Sambucelif [ -d .git ]; then
22*f4a2713aSLionel Sambuc  git remote -v | grep 'fetch' | awk '{ print $2 }' | head -n1
23*f4a2713aSLionel Sambucelse
24*f4a2713aSLionel Sambuc  exit 1;
25*f4a2713aSLionel Sambucfi
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambucexit 0
28