chiark / gitweb /
Add a couple of tools to make working with Bazaar archives more convenient.
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 12 May 2005 09:27:43 +0000 (09:27 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 12 May 2005 09:27:43 +0000 (09:27 +0000)
bazpath [new file with mode: 0755]
baztag [new file with mode: 0755]

diff --git a/bazpath b/bazpath
new file mode 100755 (executable)
index 0000000..8311b4b
--- /dev/null
+++ b/bazpath
@@ -0,0 +1,22 @@
+#! /bin/sh -e
+# Work out Bazaar archive names for branches or tags of the current
+# directory.
+
+WANTED="$1"
+ME="$(baz tree-version)"
+
+if [ "$WANTED" ]; then
+       ARCHIVE="$(baz parse-package-name --arch "$ME")"
+       CATEGORY="$(baz parse-package-name --category "$ME")"
+       case $WANTED in
+               *--*)
+                       echo "$ARCHIVE/$CATEGORY--$WANTED"
+                       ;;
+               *)
+                       VERSION="$(baz parse-package-name --vsn "$ME")"
+                       echo "$ARCHIVE/$CATEGORY--$WANTED--$VERSION"
+                       ;;
+       esac
+else
+       echo "$ME"
+fi
diff --git a/baztag b/baztag
new file mode 100755 (executable)
index 0000000..249f61a
--- /dev/null
+++ b/baztag
@@ -0,0 +1,38 @@
+#! /bin/sh -e
+
+usage () {
+       cat <<EOF
+$0 [options] VERSION
+
+Options:
+  -n, --no-act          Don't tag; just print the command that would be run.
+
+EOF
+}
+
+NOACT=
+
+if ! eval set -- "$(getopt -o n -l help,no-act -- "$@")"; then
+       usage >&2
+       exit 1
+fi
+
+while :; do
+       case $1 in
+               --help) usage; exit 0 ;;
+               -n|--no-act)
+                       NOACT=echo
+                       shift
+                       ;;
+               --)     shift; break ;;
+               *)      usage >&2; exit 1 ;;
+       esac
+done
+
+if [ $# -eq 0 ]; then
+       usage >&2
+       exit 1
+fi
+VERSION="$1"
+
+$NOACT baz branch "$(bazpath)" "$(bazpath "releases--$VERSION")"