File: authors_update.sh

package info (click to toggle)
mpich 4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,184 kB
  • sloc: ansic: 1,040,629; cpp: 82,270; javascript: 40,763; perl: 27,933; python: 16,041; sh: 14,676; xml: 14,418; f90: 12,916; makefile: 9,270; fortran: 8,046; java: 4,635; asm: 324; ruby: 103; awk: 27; lisp: 19; php: 8; sed: 4
file content (45 lines) | stat: -rwxr-xr-x 973 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env bash
#
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# See file LICENSE for terms.
#

set -eEu -o pipefail

range="${1?Provide commit range like, for example: orig/v1.17..orig/v1.18}"

if [ ! -w AUTHORS ]
then
    echo "AUTHORS file is not writable"
    exit 1
fi

# Failure message triggered if range is not valid
lines=$(git log --no-merges --pretty=format:"%an%x09%ae" "$range" | sort -u)
if [ -z "$lines" ]
then
    echo "Error: provided range \"$range\" is empty"
    exit 1
fi

tmp=$(mktemp --tmpdir=./)
grep @ AUTHORS >"$tmp"

echo "Names:"

echo -e "$lines" | \
while IFS=$'\t' read -r name email; do
    line="$name <$email>"

    # Check for known email, or identical name
    if ! grep -iqw "$email" "$tmp" && ! grep -iq "$name" "$tmp"; then
        echo "$line" >>"$tmp"
        echo "++ $line"
    else
        echo "   $line"
    fi
done

LC_COLLATE=C sort -o "$tmp"{,}
grep -v @ AUTHORS >>"$tmp"
mv "$tmp" AUTHORS