chiark / gitweb /
Add svnpath, from svn://kitenet.net/joey/trunk/bin/svnpath.
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Sat, 27 Mar 2004 10:55:12 +0000 (10:55 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Sat, 27 Mar 2004 10:55:12 +0000 (10:55 +0000)
svnpath [new file with mode: 0755]

diff --git a/svnpath b/svnpath
new file mode 100755 (executable)
index 0000000..d6a7fc4
--- /dev/null
+++ b/svnpath
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+# Work out paths in a subversion repository for branches or tags of the
+# given directory. Works on current directory by default, or it can be given
+# a path.
+
+my $wanted=shift;
+
+# Get the svn url of the current directory.
+my $url = `svn info @ARGV| grep -i ^URL: | cut -d ' ' -f 2`;
+if (! length $url) {
+       die "cannot get url";
+}
+
+if (length $wanted) {
+       # Now jut substitute into it.
+       $url=~s!/(?:trunk|branches|tags)($|/)!/$wanted$1!;
+}
+print $url;