From 9bad27f6c2b53133396dc454282d341ea9cd1f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Thu, 16 Jul 2020 21:02:06 +0200 Subject: [PATCH] show-deps: also show commit hashes --- makefiles/targets.mk | 8 ++++---- scripts/git_show_deps.sh | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100755 scripts/git_show_deps.sh diff --git a/makefiles/targets.mk b/makefiles/targets.mk index ae0d6b3..880a03d 100644 --- a/makefiles/targets.mk +++ b/makefiles/targets.mk @@ -162,11 +162,11 @@ ctags: --exclude=$(REPOS_DIR)/nim-bncurve/tests/tvectors.nim \ . -# list all Git submodule URLs, including the nested ones +# list all Git submodule URLs and commit hashes, including the nested ones show-deps: - { git config --file .gitmodules --get-regexp url | cat ;\ - git submodule foreach --quiet --recursive '[[ -f .gitmodules ]] && git config --file .gitmodules --get-regexp url | cat || true'; } \ - | cut -d ' ' -f 2 | sort -u + { "$(CURDIR)/$(BUILD_SYSTEM_DIR)/scripts/git_show_deps.sh" ;\ + git submodule foreach --quiet --recursive "$(CURDIR)/$(BUILD_SYSTEM_DIR)/scripts/git_show_deps.sh"; } \ + | sort -u ############################ # Windows-specific section # diff --git a/scripts/git_show_deps.sh b/scripts/git_show_deps.sh new file mode 100755 index 0000000..731143f --- /dev/null +++ b/scripts/git_show_deps.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +if [[ -f .gitmodules ]]; then + git config --file .gitmodules --get-regexp 'path|url' | while read TMP S_PATH && read TMP S_URL; do + # we probably can't rely on that leading space always being there + S_HASH=$(git submodule status --cached "${S_PATH}" | sed 's/^\s*\(\S\+\).*$/\1/') + echo "${S_URL} ${S_HASH}" + done +fi +