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