From f35692daa619227abf205cc0c66e45da187e47b9 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Wed, 20 Jun 2018 16:06:43 -0400 Subject: [PATCH] Allow showing git diff interactively to inspect release commits. --- build-support/functions/10-util.sh | 33 +++++++++++++++++++++++++++ build-support/functions/40-publish.sh | 7 +++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/build-support/functions/10-util.sh b/build-support/functions/10-util.sh index e796a76f2a..e997ccd2c4 100644 --- a/build-support/functions/10-util.sh +++ b/build-support/functions/10-util.sh @@ -319,6 +319,39 @@ function git_log_summary { return $ret } +function git_diff { + # Arguments: + # $1 - Path to the git repo (optional - assumes pwd is git repo otherwise) + # $2 .. $N - Optional path specification + # + # Returns: + # 0 - success + # * - failure + # + + local gdir="$(pwd)" + if test -d "$1" + then + gdir="$1" + fi + + shift + + pushd "${gdir}" > /dev/null + + local ret=0 + + local head=$(git_branch) || ret=1 + local upstream=$(git_upstream) || ret=1 + + if test ${ret} -eq 0 + then + status "Git Diff - Paths: $@" + git diff ${HEAD} ${upstream} -- "$@" || ret=1 + fi + return $ret +} + function normalize_git_url { url="${1#https://}" url="${url#git@}" diff --git a/build-support/functions/40-publish.sh b/build-support/functions/40-publish.sh index 2e5546cef0..3376ef168a 100644 --- a/build-support/functions/40-publish.sh +++ b/build-support/functions/40-publish.sh @@ -97,8 +97,13 @@ function confirm_git_push_changes { ret=1 break ;; + ?) + # bindata_assetfs.go will make these meaningless + git_diff "$(pwd)" ":!agent/bindata_assetfs.go"|| ret 1 + answer="" + ;; * ) - read -p "Are these changes correct? [y/n]: " answer + read -p "Are these changes correct? [y/n] (or type ? to show the diff output): " answer ;; esac done