From 11548bcc85f6f347f1b3a924060f45c3d1715c0b Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Mon, 3 Aug 2020 07:36:41 -0500 Subject: [PATCH] Add mpbb-port-commit --- mpbb-port-commit | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 mpbb-port-commit diff --git a/mpbb-port-commit b/mpbb-port-commit new file mode 100644 index 0000000..79bead3 --- /dev/null +++ b/mpbb-port-commit @@ -0,0 +1,31 @@ +#!/bin/bash +# -*- coding: utf-8; mode: sh; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=sh:et:sw=4:ts=4:sts=4 + +# Note: +# This script is sourced by the mpbb wrapper script. +# Do not execute this directly! + +port-commit-usage() { + # "prog" is defined in mpbb-help. + # shellcheck disable=SC2154 + cat <] port-commit + +Print the latest commit hash of the given port. + +Run \`$prog help' for global options and a list of other subcommands. +EOF +} + +port-commit() { + local port=${1-} + if [[ -z $port ]]; then + err "Must specify a port" + return 1 + fi + + # $option_prefix is set in mpbb + # shellcheck disable=SC2154 + portdir=$("${option_prefix}/bin/port" dir "$port") || return + git -C "$portdir" log -n 1 --pretty=format:%H . +}