Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a script to print markdown list of submodule states #1256

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions scripts/state
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
# scripts/state
# display the state of ldmx-sw
#
# REQUIREMENTS
# - awk availabe
# - git has the '-C' flag (>= 1.8.5)
# - all the submodules have their remotes named 'origin'

set -o errexit
set -o nounset

git submodule foreach --recursive git fetch --tags
git submodule status --recursive | awk '{
# git submodule status returns lines of the form
# <commit> <submodule> (<version>)
# where <version> is either the tag, branch name, or something else
# $1 - commit
# $2 - submodule
# $3 - version
# strip the parentheses from the version string
gsub(/\(|\)/,"",$3);
# retrieve the URL to the repo
# assumes the remote is named "origin" in all the submodules
git_repo_url="git -C "$2" remote get-url origin";
git_repo_url | getline repo_url;
close(git_repo_url);
# change any SSH remote links back to https
gsub(/.git$/,"",repo_url);
gsub(/^git@/,"https://",repo_url);
gsub(/com:/,"com/",repo_url);
# if the version matches a version string, link to a release page,
# otherwise just link to the commit page
# this is where we use the fact that GitHub links are formulaic
# across repositories
if ($3 ~ /^v[0-9]*\.[0-9]*\.[0-9]*$/)
printf "- [%s %s](%s/releases/tag/%s)\n", $2, $3, repo_url, $3
else
printf "- [%s %s](%s/commit/%s)\n", $2, substr($1,1,8), repo_url, $1
}'

Loading