|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Example usage: |
| 4 | +# mkdir -p reference |
| 5 | +# for VERSION in v1.0.0 HEAD; do |
| 6 | +# ./scripts/authors-by-version.sh $VERSION > reference/authors-$VERSION.md |
| 7 | +# done |
| 8 | + |
| 9 | +# Authors, comitters, co-authors |
| 10 | +get_authors() { |
| 11 | + local git_tag="$1" |
| 12 | + shift # Shift arguments to get the files |
| 13 | + local files="$*" |
| 14 | + # shellcheck disable=SC2086 |
| 15 | + git --no-pager log "$git_tag" -- $files | \ |
| 16 | + sed -n -e 's/^Author: //p' -e 's/^Committer: //p' -e 's/^.*Co-authored-by: //p' | \ |
| 17 | + sort -u | sed -e 's/^/- /' |
| 18 | +} |
| 19 | + |
| 20 | +# Ensure tag argument is provided |
| 21 | +GIT_TAG=$1 |
| 22 | + |
| 23 | +if [[ -z ${GIT_TAG} ]]; then |
| 24 | + echo "Usage: $0 <git-tag>" |
| 25 | + exit 1 |
| 26 | +fi |
| 27 | + |
| 28 | +if [ ! "$(git tag -l "$GIT_TAG")" ] && [ ! "$GIT_TAG" == "HEAD" ]; then |
| 29 | + echo "<git-tag> '$GIT_TAG' does not exist" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +# Check if translations |
| 34 | +git show "$GIT_TAG":i18n > /dev/null 2>&1 && i18n=true || i18n=false |
| 35 | + |
| 36 | + |
| 37 | +# Output |
| 38 | +cat <<EOF |
| 39 | +# $GIT_TAG Authors |
| 40 | +
|
| 41 | +⚠️ Do not edit this file directly. |
| 42 | +It is [auto-generated](../scripts/authors-by-version.sh) from Git history of source files in this repo. |
| 43 | +
|
| 44 | +ℹ️ Note this is purely a convenience for referencing in academic papers. |
| 45 | +See the full Git history of specific files for additional context. |
| 46 | +
|
| 47 | +EOF |
| 48 | + |
| 49 | +# If translations exist, output a note about language and translations |
| 50 | +if [[ $i18n = true ]]; then |
| 51 | + cat <<EOF |
| 52 | +## Language and Translations |
| 53 | +
|
| 54 | +The GitOps Principles and Glossary are [authored](#authors-list) in English. |
| 55 | +See farther below for a list of [translators](#translators-list) by language. |
| 56 | +
|
| 57 | +EOF |
| 58 | +fi |
| 59 | + |
| 60 | +# Get authors list |
| 61 | +AUTHORS=$(get_authors "$GIT_TAG" "PRINCIPLES.md GLOSSARY.md") |
| 62 | + |
| 63 | +# Append to output |
| 64 | +cat <<EOF |
| 65 | +## Authors List |
| 66 | +
|
| 67 | +$AUTHORS |
| 68 | +EOF |
| 69 | + |
| 70 | +# If translations exist, append translator lists |
| 71 | +if [[ $i18n = true ]]; then |
| 72 | + # Get translator lists |
| 73 | + DE=$(get_authors "$GIT_TAG" i18n/*_de.md) |
| 74 | + ES=$(get_authors "$GIT_TAG" i18n/*_es.md) |
| 75 | + PT=$(get_authors "$GIT_TAG" i18n/*_pt.md) |
| 76 | + FR=$(get_authors "$GIT_TAG" i18n/*_fr.md) |
| 77 | + |
| 78 | + # Append to output |
| 79 | + cat <<EOF |
| 80 | +
|
| 81 | +## Translators List |
| 82 | +
|
| 83 | +### German |
| 84 | +
|
| 85 | +$DE |
| 86 | +
|
| 87 | +### Spanish |
| 88 | +
|
| 89 | +$ES |
| 90 | +
|
| 91 | +### Portuguese |
| 92 | +
|
| 93 | +$PT |
| 94 | +
|
| 95 | +### French |
| 96 | +
|
| 97 | +$FR |
| 98 | +EOF |
| 99 | +fi |
0 commit comments