Created
May 5, 2017 07:12
-
-
Save o11c/cc3520bda444f2b26717952f02e51bf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# For repositories cloned using `git-remote-bzr` (the official one), | |
# convert a git commit hash to the bzr hash *and* revno. | |
set -e | |
die() | |
{ | |
printf '%s\n' "$1" >&2 | |
exit 1 | |
} | |
case "$#" in | |
0) what=HEAD;; | |
1) what="$1";; | |
*) die 'Error: too many arguments';; | |
esac | |
case "$what" in | |
-*) die "Usage: $0 [git-revision]";; | |
esac | |
cd "$(git rev-parse --git-dir)" | |
what="$(git rev-parse "$what")" | |
mark="$(cat bzr/origin/marks-git | grep ' '"$what"'$' | sed 's/^://;s/ .*$//')" | |
bzr_id="$(cat bzr/origin/marks-int | jq --raw-output --argjson mark "$mark" ' | |
.marks | |
| to_entries | |
| map(select(.value == $mark)) | |
| .[0].key | |
')" | |
echo "$bzr_id" | |
bzr revno bzr/origin/clone/master/.bzr -r "$bzr_id" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment