-
Notifications
You must be signed in to change notification settings - Fork 19
/
release-contributors.sh
executable file
·122 lines (105 loc) · 2.97 KB
/
release-contributors.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash -u
function print_usage {
echo "Usage example:"
echo " ${0} --os-baseline stable/yoga \\"
echo " --ovn-baseline stable/22.03 \\"
echo " --ceph-baseline stable/quincy \\"
echo " --libs-dir ./libs-dir \\"
echo " --output contributors.txt"
}
#set -e # Enabling this can break the script for any newly introduced charms
CLEAN=0
LAST_REF=master
BASE_DIR=
OUTPUT=
declare -A BASELINE_BRANCHES
# parse cli arguments
while (($# > 0))
do
case "$1" in
--clean)
CLEAN=1
;;
--os-baseline)
BASELINE_BRANCHES["openstack"]=$2
shift
;;
--ovn-baseline)
BASELINE_BRANCHES["ovn"]=$2
shift
;;
--ceph-baseline)
BASELINE_BRANCHES["ceph"]=$2
shift
;;
--libs-dir)
BASE_DIR=$2
shift
;;
--output)
OUTPUT=$2
shift
;;
*)
echo "ERROR: invalid input '$1'"
print_usage
exit 1
;;
esac
shift
done
if [ -z $BASE_DIR ] || [ "${#BASELINE_BRANCHES[@]}" -eq 0 ]; then
print_usage
exit 2
fi
function log {
echo "$(date '+%H:%M:%S') $@" >&2
}
RELEASE_TOOLS_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# directory where there are git clones of the repositories
CHARMS_DIR=$RELEASE_TOOLS_DIR/charms
EXTRA_DIRS=("${BASE_DIR}/release-tools"
"${BASE_DIR}/charms.openstack"
"${BASE_DIR}/charms.ceph"
"${BASE_DIR}/charm-guide"
"${BASE_DIR}/charm-deployment-guide")
# Update each repository (needed?)
for DIR in ${EXTRA_DIRS[@]}; do
log "updating repository ${DIR}"
git -C $DIR pull --ff-only origin master
done
ALL_CONTRIBUTORS_FILE=$(mktemp -t "users_tmp.XXXX")
SUMMARY_FILE=$(mktemp -t "users-summary.XXXX")
# Clean up before collecting stats.
rm $ALL_CONTRIBUTORS_FILE
if [ $CLEAN == 1 ]; then
rm -rf $CHARMS_DIR
fi
pushd $RELEASE_TOOLS_DIR
for GROUP in "${!BASELINE_BRANCHES[@]}"; do
./fetch-charms.py -s "${GROUP}" -d $CHARMS_DIR/${GROUP}/
for DIR in ${CHARMS_DIR}/${GROUP}/*/; do
log "Processing charm ${DIR}..."
if $(git -C $DIR branch -r | grep -q origin/stable/"${BASELINE_BRANCHES[$GROUP]}"); then
git -C $DIR log --format="%an" origin/stable/"${BASELINE_BRANCHES[$GROUP]}"..${LAST_REF} 2>/dev/null >> $ALL_CONTRIBUTORS_FILE
else
echo Repo $DIR does not have branch origin/stable/"${BASELINE_BRANCHES[$GROUP]}", skipping
fi
done
done
# Libraries
for DIR in ${EXTRA_DIRS[@]}; do
log "Processing repository ${DIR}"
git -C $DIR log --format="%an" origin/stable/"${BASELINE_BRANCHES[openstack]}"..master 2>/dev/null >> $ALL_CONTRIBUTORS_FILE
done
# Collate the results
cat $ALL_CONTRIBUTORS_FILE | grep -v Zuul | sort | uniq > "${SUMMARY_FILE}"
CONTRIB_NUMBER=$(wc -l $SUMMARY_FILE | awk '{print $1}')
echo -e "\n${CONTRIB_NUMBER} different people contributed since release ${BASELINE_BRANCHES[@]}."
echo ""
if [ -z $OUTPUT ]; then
cat ${SUMMARY_FILE}
else
cp ${SUMMARY_FILE} $OUTPUT
echo "See file ${OUTPUT}"
fi