blob: 0cd137abaf283261cce99af41c5d511957650363 [file] [log] [blame]
#!/bin/bash
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Opens the given commit ref (or HEAD) if no commit ref is passed in gerrit.
#
# Example: `git fuchsia-review <commit hash>`, `git fuchsia-review`.
usage() {
printf 'usage: git fuchsia-review [<commit ref>]\n'
exit 0
}
set -e
if [[ ($1 == "-h") || ($1 == "--help") ]]
then
usage;
fi
ID=`git show $1 | grep -E 'Change-Id' | awk '{print $(NF);}'`
URL="https://fuchsia-review.googlesource.com/q/$ID"
echo Opening Change-Id $ID
if [[ "$OSTYPE" == "darwin"* ]]; then
open $URL
else
xdg-open $URL
fi