Finish get_contributors.sh
authorvarac <varacanero@zeromail.org>
Wed, 31 May 2017 21:15:31 +0000 (23:15 +0200)
committervarac <varacanero@zeromail.org>
Wed, 31 May 2017 21:15:31 +0000 (23:15 +0200)
get_contributors.sh

index 49ed580..eaae0d0 100755 (executable)
@@ -9,30 +9,31 @@ REPOS=(bitmask_android bitmask_bundler bitmask_client bitmask-dev bitmask_help b
 # shellcheck disable=SC2016
 GET_CONTRIBUTORS='git log --branches --not --remotes=subrepo --use-mailmap --format="%aN <%aE>" | awk "{arr[\$0]++} END{for (i in arr){print arr[i], i;}}" | sort -rn | cut -d" " -f2- | sort'
 ROOTDIR="${HOME}/leap/git"
-LISTFILE='/tmp/contributors.txt'
 
 # optional specify core team memebers to filter out
 TEAM='(email@of.contributor.org|email@of_other_contributor.net)'
 
-[ -e ${LISTFILE} ] && rm ${LISTFILE}
-[ -e ${LISTFILE}.tmp ] && rm ${LISTFILE}.tmp
+declare -A contributors
 
 for repo in "${REPOS[@]}"
 do
   cd "${ROOTDIR}/${repo}" || exit 1
   # Uncomment for first run to make sure all repos are up to date
   # git fetch
-  contributors=$(eval "$GET_CONTRIBUTORS" | egrep --text -iv "$TEAM")
-  if [ -n "$contributors" ]
+  contributors_repo=$(eval "$GET_CONTRIBUTORS" | egrep --text -iv "$TEAM")
+  if [ -n "$contributors_repo" ]
   then
     echo "${repo}:"
-    echo "$contributors" | tee -a ${LISTFILE}.tmp
+    while read -r line; do
+      echo "$line"
+      contributors["$line"]+="$repo, "
+    done <<< "$contributors_repo"
     echo
     echo
   fi
 done
 
+echo
+echo
 
-sort < "${LISTFILE}.tmp" | uniq  > "${LISTFILE}"
-rm "${LISTFILE}.tmp"
-echo "Complete list of contributors is at ${LISTFILE}"
+for contributor in "${!contributors[@]}"; do echo "$contributor: ${contributors[$contributor]}"; done | sort