status: add branch info, improv formatting

This commit is contained in:
pedro 2024-02-29 17:34:52 +01:00
parent 306dcbcbd2
commit 95fcb786bd

View file

@ -10,8 +10,10 @@ _git_info() {
d="${1}"
cd ${d}
# src https://stackoverflow.com/questions/6245570/how-do-i-get-the-current-branch-name-in-git/6245587#6245587
branch_info="$(git branch --show-current)"
# src https://ma.ttias.be/pretty-git-log-in-one-line/
commit_info="$(git log --pretty=format:'[%ci] %h %an: %s' -n 1)"
commit_info="$(git log --pretty=format:'%H [%ci] %h %an: %s' -n 1)"
cd - >/dev/null
d_name="$(basename "${d}")"
}
@ -25,7 +27,7 @@ main() {
| sort -u
)"
_git_info ./ssikit_trustchain
printf -- "%-31s | commit: %s\n" "${d_name}" "${commit_info}"
printf -- "%-31s | branch: %8s | commit: %s\n" "${d_name}" "${branch_info}" "${commit_info}"
printf -- " note: outdated ssikit_trustchain version could be present on any instance. Hence, this only relevant for new or fresh builds\n\n"
for i in ${instances}; do
dirs="$(find . -maxdepth 1 -type d \
@ -35,7 +37,7 @@ main() {
echo "- ${i}"
for d in ${dirs}; do
_git_info "${d}"
printf -- " - %-25s | commit: %s\n" "${d_name}" "${commit_info}"
printf -- " - %-25s | branch: %-8s | commit: %s\n" "${d_name}" "${branch_info}" "${commit_info}"
done
done
}