Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # This file is part of the coreboot project. |
| 4 | # |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 5 | # Copyright 2015-2016 Google Inc. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; version 2 of the License. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 16 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 17 | # This script creates a list of commits between two releases, broken out into |
| 18 | # fairly inexact categories, based on the directories that files are in. If |
| 19 | # a commit touched anything in the path that is checked earlier, it's counted |
| 20 | # as being in that category. |
| 21 | # |
| 22 | # Don't run this in your current working tree, it checks out different versions |
| 23 | # and can lose things. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 24 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 25 | # set -x # uncomment for debug |
| 26 | |
| 27 | # Check for tools |
| 28 | |
| 29 | if ! ( git --version cloc --version ) > /dev/null 2>&1 |
| 30 | then |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 31 | echo "ERROR: cloc or git is not installed. Exiting" |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 35 | if [ ! -e ".git" ];then |
| 36 | echo "ERROR: This is not the top directory of a git repo. Exiting." |
| 37 | exit 1 |
| 38 | fi |
| 39 | |
| 40 | # Try to verify that the repo is clean before losing state. |
| 41 | if ! git diff-index --quiet --cached HEAD 2>/dev/null || \ |
| 42 | [ "$(git diff origin/master --shortstat 2>/dev/null | tail -n1)" != "" ]; then |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 43 | echo "ERROR: repo is not clean. Exiting." |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 47 | if grep -q 'review.coreboot.org' .git/config; then |
| 48 | COREBOOT=1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 49 | else |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 50 | echo "This doesn't look like a coreboot repo. Disabling coreboot specifics" |
| 51 | COREBOOT=0 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 52 | fi |
| 53 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 54 | # Verify the command line arguments |
| 55 | if [ "$1" == "--help" ] || [ -z "$1" ] || [ -z "$2" ]; then |
| 56 | echo |
| 57 | echo "Usage: $0 <old_version> <new_version> [release notes file]" |
| 58 | echo "Old version should be a tag (4.1), a branch (origin/4.1), or a commit id" |
| 59 | echo "New version can be 'HEAD' a branch (origin/master) a tag (4.2), or a commit id" |
| 60 | echo "Logfile can be a new file or an existing file to update" |
| 61 | echo "Example: \"$0 origin/4.1 4.2 rnotes.txt\"" |
| 62 | echo |
| 63 | echo "Note that the script starts at the commit AFTER the old version." |
| 64 | echo |
| 65 | exit 1 |
| 66 | else |
| 67 | OLD_GIT_VERSION="$1" |
| 68 | NEW_GIT_VERSION="$2" |
| 69 | TOTAL_COMMITS=$(git log --pretty=oneline \ |
| 70 | "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | wc -l) |
| 71 | fi |
| 72 | |
| 73 | TOP=$(pwd) |
| 74 | |
| 75 | if [ -n "$3" ]; then |
| 76 | MAIN_LOGFILE="${TOP}/$3" |
| 77 | else |
| 78 | MAIN_LOGFILE="${TOP}/relnotes.txt" |
| 79 | fi |
| 80 | |
| 81 | # Figure out which logfile we're writing to. If the specified logfile exists, |
| 82 | # we need to write to a temporary logfile, then append changes to the main |
| 83 | # logfile. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 84 | if [ -f "$MAIN_LOGFILE" ]; then |
| 85 | LOGFILE="$(mktemp "LOGFILE.XXXX")" |
| 86 | LOGFILE="${TOP}/$LOGFILE" |
| 87 | UPDATE_MAIN_LOGFILE=1 |
| 88 | else |
| 89 | LOGFILE="$MAIN_LOGFILE" |
| 90 | fi |
| 91 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 92 | |
| 93 | |
| 94 | get_author_commit_count() { |
| 95 | git log "${NEW_GIT_VERSION}" 2>/dev/null | grep -c "^Author: $1" |
| 96 | } |
| 97 | |
| 98 | # Print and log the versions |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 99 | log_versions() { |
| 100 | echo "Log of commit $1 to commit $2" |
| 101 | echo "Log of commit $1 to commit $2" >> "$LOGFILE" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 102 | echo "Total commits: ${TOTAL_COMMITS}" |
| 103 | echo "Total commits: ${TOTAL_COMMITS}" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 104 | echo |
| 105 | } |
| 106 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 107 | # Get the first commit id in the current tree |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 108 | get_latest_commit_id() { |
| 109 | pushd "$1" > /dev/null |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 110 | git log 2>/dev/null | grep '^commit ' | head -1 | sed 's/commit //' |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 111 | popd > /dev/null |
| 112 | } |
| 113 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 114 | # Main get log function |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 115 | _get_log() { |
| 116 | local oldver="$1" |
| 117 | local newver="$2" |
| 118 | local title="$3" |
| 119 | local paths="$4" |
| 120 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 121 | # Leave ${paths} unquoted |
| 122 | # shellcheck disable=SC2086 |
| 123 | git log --abbrev-commit --pretty=oneline \ |
| 124 | "${oldver}..${newver}" -- ${paths} 2>/dev/null | \ |
| 125 | sort -t ' ' -k 2 | \ |
| 126 | uniq |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 129 | # Output to a new log, then compare to the first logfile, and only output |
| 130 | # non duplicated lines to the final file. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 131 | get_log_dedupe() { |
| 132 | local title="$1" |
| 133 | local paths="$2" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 134 | local log |
| 135 | local commits |
| 136 | |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 137 | dedupe_tmpfile="$(mktemp "LOGFILE.XXXX")" |
| 138 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 139 | log=$(_get_log "$OLD_GIT_VERSION" "$NEW_GIT_VERSION" \ |
| 140 | "$title" "$paths") |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 141 | |
| 142 | echo "$log" > "$dedupe_tmpfile" |
| 143 | |
| 144 | log=$(grep -Fxv -f "$LOGFILE" "$dedupe_tmpfile") |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 145 | commits=$(echo "$log" | wc -l) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 146 | |
| 147 | if [ -n "$log" ]; then |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 148 | printf "%s\n%s\n\n" "$title ($commits commits)" \ |
| 149 | "$log" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 150 | fi |
| 151 | |
| 152 | rm "$dedupe_tmpfile" |
| 153 | } |
| 154 | |
| 155 | # get logs for the submodules |
| 156 | get_log_submodule() { |
| 157 | local old_version="$1" |
| 158 | local new_version="$2" |
| 159 | local submodule_dir="$3" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 160 | local log |
| 161 | local commits |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 162 | |
| 163 | printf "Submodule %s\n" "$submodule_dir" |
| 164 | printf "commit %s to commit %s\n\n" "$old_version" "$new_version" |
| 165 | |
| 166 | pushd "${TOP}/$submodule_dir" > /dev/null |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 167 | log=$(_get_log "$old_version" "$new_version" "$submodule_dir" ".") |
| 168 | commits=$(echo "$log" | wc -l) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 169 | |
| 170 | if [ -n "$log" ]; then |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 171 | printf "%s\n%s\n\n" "$submodule_dir ($commits commits)" \ |
| 172 | "$log" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 173 | fi |
| 174 | |
| 175 | popd > /dev/null |
| 176 | } |
| 177 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 178 | find_areas() { |
| 179 | find "$1" -name "$2" | sed "s|$1/||" | sed "s|/$2||" | sort |
| 180 | } |
| 181 | |
| 182 | # Make sure things get cleaned up if ctl-c is pressed while the old version |
| 183 | # is checked out and files are renamed. This can be a real mess to clean |
| 184 | # up manually. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 185 | version_ctrl_c() { |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 186 | printf "\n** Trapped CTRL-C\n Cleaning up and exiting.\n" |
| 187 | find 'src' -name 'gnumakefile' \ |
| 188 | -exec rename 's/gnumakefile/Makefile\.inc/' {} \; |
| 189 | git checkout origin/master > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 190 | git submodule update --init --checkout > /dev/null 2>&1 |
| 191 | rm -f "$mainboard_list_old" "$mainboard_list_new" |
| 192 | rm "$LOGFILE" |
| 193 | exit 1; |
| 194 | } |
| 195 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 196 | # Calculate areas that have been added or removed based on file lists |
| 197 | show_diff () { |
| 198 | local new |
| 199 | local old |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 200 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 201 | new="$(comm -13 <(echo "$2") <(echo "$3"))" |
| 202 | if [ -n "$new" ]; then |
| 203 | printf "Added %s $1:\n-------------------\n%s\n\n" \ |
| 204 | "$(echo "$new" | wc -l)" "$new" >> "$LOGFILE" |
| 205 | fi |
| 206 | old="$(comm -23 <(echo "$2") <(echo "$3"))" |
| 207 | if [ -n "$old" ]; then |
| 208 | printf "Removed %s $1:\n-------------------\n%s\n\n" \ |
| 209 | "$(echo "$old" | wc -l)" "$old" >> "$LOGFILE" |
| 210 | fi |
| 211 | } |
| 212 | |
| 213 | # Start collecting data from the old and new revisions. |
| 214 | # This is relatively disruptive to the tree, so trap on ctl-c so that |
| 215 | # things can be put back to normal |
| 216 | trap version_ctrl_c SIGINT |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 217 | |
| 218 | #check out old version and get information |
| 219 | printf -- "Finding old submodule versions...\n" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 220 | git checkout "$OLD_GIT_VERSION" > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 221 | git submodule update --init --checkout > /dev/null 2>&1 |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 222 | if [ "$COREBOOT" -eq "1" ]; then |
| 223 | BLOBS_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/blobs") |
| 224 | VBOOT_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/vboot") |
| 225 | ARM_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/arm-trusted-firmware") |
| 226 | CHROME_EC_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/chromeec/") |
| 227 | NVIDIA_OLD_VERSION=$(get_latest_commit_id "${TOP}/util/nvidia/cbootimage") |
| 228 | |
| 229 | printf "Logging directories in the old tree\n" |
| 230 | mainboard_list_old=$(find_areas "src/mainboard" 'Kconfig.name' | grep '/') |
| 231 | cpu_list_old=$(find_areas "src/cpu" "Kconfig") |
| 232 | soc_list_old=$(find_areas "src/soc" "Kconfig") |
| 233 | northbridge_list_old=$(find_areas "src/northbridge" "Kconfig") |
| 234 | sio_list_old=$(find_areas "src/superio" "Makefile.inc") |
| 235 | southbridge_list_old=$(find_areas "src/southbridge" "Kconfig") |
| 236 | |
| 237 | # Because cloc works on extensions, and .inc identifies as pascal, |
| 238 | # rename Makefile.inc, then remap the other .inc files to c |
| 239 | find 'src' -name 'Makefile.inc' -exec rename 's/Makefile\.inc/gnumakefile/' {} \; |
| 240 | fi |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 241 | printf "Calculating old SLOC\n" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 242 | OLD_SLOC=$(cloc --progress-rate=0 --quiet --script-lang="Bourne Shell",bash \ |
| 243 | --force-lang=c,inc --exclude-dir=vendorcode src) |
| 244 | if [ "$COREBOOT" -eq "1" ]; then |
| 245 | find 'src' -name 'gnumakefile' -exec rename 's/gnumakefile/Makefile\.inc/' {} \; |
| 246 | fi |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 247 | |
| 248 | #check out new version and get information |
| 249 | printf -- "\nFinding new submodule versions...\n" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 250 | git checkout "$NEW_GIT_VERSION" > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 251 | git submodule update --init --checkout > /dev/null 2>&1 |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 252 | if [ "$COREBOOT" -eq "1" ]; then |
| 253 | BLOBS_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/blobs") |
| 254 | VBOOT_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/vboot") |
| 255 | ARM_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/arm-trusted-firmware") |
| 256 | CHROME_EC_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/chromeec/") |
| 257 | NVIDIA_NEW_VERSION=$(get_latest_commit_id "${TOP}/util/nvidia/cbootimage") |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 258 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 259 | printf "Logging directories in the new tree\n" |
| 260 | mainboard_list_new=$(find_areas "src/mainboard" 'Kconfig.name' | grep '/') |
| 261 | cpu_list_new=$(find_areas "src/cpu" "Kconfig") |
| 262 | soc_list_new=$(find_areas "src/soc" "Kconfig") |
| 263 | northbridge_list_new=$(find_areas "src/northbridge" "Kconfig") |
| 264 | sio_list_new=$(find_areas "src/superio" "Makefile.inc") |
| 265 | southbridge_list_new=$(find_areas "src/southbridge" "Kconfig") |
| 266 | |
| 267 | find 'src' -name 'Makefile.inc' -exec rename 's/Makefile\.inc/gnumakefile/' {} \; |
| 268 | fi |
| 269 | printf "Calculating new SLOC\n" |
| 270 | NEW_SLOC=$(cloc --progress-rate=0 --quiet --script-lang="Bourne Shell",bash \ |
| 271 | --force-lang=c,inc --exclude-dir=vendorcode src) |
| 272 | if [ "$COREBOOT" -eq "1" ]; then |
| 273 | find 'src' -name 'gnumakefile' -exec rename 's/gnumakefile/Makefile\.inc/' {} \; |
| 274 | fi |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 275 | |
| 276 | git checkout origin/master > /dev/null 2>&1 |
| 277 | git submodule update --init --checkout > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 278 | trap "" SIGINT |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 279 | # Done collecting data from the old and new versions |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 280 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 281 | # Start outputting to logfile |
| 282 | echo "Generating release notes from version ${OLD_GIT_VERSION} to ${NEW_GIT_VERSION}" |
| 283 | echo; echo "Main repo" |
| 284 | echo "Main repo" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 285 | echo "------------------" >> "$LOGFILE" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 286 | log_versions "$(git log --pretty=%H \ |
| 287 | "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | tail -1)" \ |
| 288 | "$(git log --pretty=%H \ |
| 289 | "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | head -1 )" |
| 290 | echo "" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 291 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 292 | if [ "$COREBOOT" -eq "1" ]; then |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 293 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 294 | # 1st, Show mainboards so that changes that are mainboard specific don't get |
| 295 | # grabbed by changes in the architectures |
| 296 | get_log_dedupe "Mainboards" "src/mainboard/" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 297 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 298 | # Show architectures 2nd - separate the various pieces out |
| 299 | # This works by getting a list of directories that have Kconfigs containing _ARCH |
| 300 | # then filtering out generic areas. X86 has too many non-compliant directories |
| 301 | # for that to work well, so just supply a list |
| 302 | # shellcheck disable=SC2013 |
| 303 | { |
| 304 | get_log_dedupe "ARM" \ |
| 305 | "$(for codedir in $(grep -rl "_ARM" --include=Kconfig | \ |
| 306 | grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \ |
| 307 | do dirname "$codedir"; done | grep -v '^src$')" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 308 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 309 | get_log_dedupe "RISC-V" \ |
| 310 | "$(for codedir in $(grep -rl "_RISCV" --include=Kconfig | \ |
| 311 | grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \ |
| 312 | do dirname "$codedir"; done | grep -v '^src$')" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 313 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 314 | get_log_dedupe "X86" \ |
| 315 | "src/arch/x86 src/cpu/x86 src/cpu/intel src/soc/intel src/cpu/amd \ |
| 316 | src/northbridge/intel src/northbridge/amd src/southbridge/intel \ |
| 317 | src/southbridge/amd src/drivers/intel/fsp1_0 src/drivers/intel/fsp1_1 \ |
| 318 | src/include/amd src/include/intel src/include/x86 src/include/pc80" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 319 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 320 | get_log_dedupe "MIPS" \ |
| 321 | "$(for codedir in $(grep -rl "_MIPS" --include=Kconfig | \ |
| 322 | grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \ |
| 323 | do dirname "$codedir"; done | grep -v '^src$')" |
| 324 | } |
| 325 | # Next, print all the rest of the specific areas |
| 326 | get_log_dedupe "ACPI" "src/acpi/" |
| 327 | get_log_dedupe "Console" "src/console/ src/include/console" |
| 328 | get_log_dedupe "SuperIO" "src/superio/ src/include/superio" |
| 329 | get_log_dedupe "EC " "src/ec" |
| 330 | get_log_dedupe "Drivers" "src/drivers/" |
| 331 | get_log_dedupe "Devices" "src/device/ src/include/device" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 332 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 333 | # 5th, print the generic areas - This goes late so that the specific |
| 334 | # area changes will catch any commits in these areas first. |
| 335 | get_log_dedupe "Lib" "src/lib/" |
| 336 | get_log_dedupe "Commonlib" "src/commonlib/" |
| 337 | get_log_dedupe "Include" "src/include/" |
| 338 | get_log_dedupe "Utilities" "util/" |
| 339 | get_log_dedupe "Payloads" "payloads/" |
| 340 | get_log_dedupe "Vendorcode" "src/vendorcode/" |
| 341 | get_log_dedupe "Documentation" "Documentation/ README" |
| 342 | |
| 343 | # Then look at areas that are usually outside the mainboards and architectures |
| 344 | get_log_dedupe "Build system" \ |
| 345 | "Makefile Makefile.inc toolchain.inc src/Kconfig src/cpu/Makefile.inc" |
| 346 | |
| 347 | # Finally, get anything that was missed above |
| 348 | get_log_dedupe "MISC" "." |
| 349 | |
| 350 | # Show areas that have been added or removed |
| 351 | show_diff "mainboards" "$mainboard_list_old" "$mainboard_list_new" |
| 352 | show_diff "processors" "$cpu_list_old" "$cpu_list_new" |
| 353 | show_diff "socs" "$soc_list_old" "$soc_list_new" |
| 354 | show_diff "northbridges" "$northbridge_list_old" "$northbridge_list_new" |
| 355 | show_diff "southbridges" "$southbridge_list_old" "$southbridge_list_new" |
| 356 | show_diff "sios" "$sio_list_old" "$sio_list_new" |
| 357 | |
| 358 | # Log submodules |
| 359 | printf "Submodules\n----------\n" >> "$LOGFILE" |
| 360 | get_log_submodule "$BLOBS_OLD_VERSION" "$BLOBS_NEW_VERSION" \ |
| 361 | "3rdparty/blobs" |
| 362 | get_log_submodule "$ARM_OLD_VERSION" "$ARM_NEW_VERSION" \ |
| 363 | "3rdparty/arm-trusted-firmware" |
| 364 | get_log_submodule "$VBOOT_OLD_VERSION" "$VBOOT_NEW_VERSION" \ |
| 365 | "3rdparty/vboot" |
| 366 | get_log_submodule "$CHROME_EC_OLD_VERSION" "$CHROME_EC_NEW_VERSION" \ |
| 367 | "3rdparty/chromeec/" |
| 368 | get_log_submodule "$NVIDIA_OLD_VERSION" "$NVIDIA_NEW_VERSION" \ |
| 369 | "util/nvidia/cbootimage" |
| 370 | |
| 371 | else |
| 372 | get_log_dedupe "Commits" "." |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 373 | fi |
| 374 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 375 | printf "\nrepo statistics\n-------------------\n" >> "$LOGFILE" |
| 376 | before_names="$(mktemp "OLDNAMES.XXXX")" |
| 377 | after_names="$(mktemp "NEWNAMES.XXXX")" |
| 378 | NEW_AUTHORS=$(git log --pretty=%an "${OLD_GIT_VERSION}" 2>/dev/null | sort | \ |
| 379 | uniq > "$before_names" && \ |
| 380 | git log --pretty=%an "${NEW_GIT_VERSION}" 2>/dev/null | \ |
| 381 | sort | uniq > "$after_names" && \ |
| 382 | grep -Fxv -c -f "$before_names" "$after_names") |
| 383 | NEW_AUTHOR_LIST=$( grep -Fxv -f "$before_names" "$after_names" && \ |
| 384 | rm "$before_names" "$after_names") |
| 385 | { |
| 386 | printf -- "- Total commits: %s\n" "$TOTAL_COMMITS" |
| 387 | printf -- "- Total authors: %s\n" \ |
| 388 | "$(git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | \ |
| 389 | grep -e '^Author:' | sed 's/.*Author: //' | sed 's/ <.*.>//' | \ |
| 390 | sort | uniq | wc -l)" |
| 391 | printf -- "- New authors: %s\n\nNew Authors:\n%s\n" "$NEW_AUTHORS" \ |
| 392 | "$NEW_AUTHOR_LIST" |
| 393 | } >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 394 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 395 | printf "Getting developer list\n" |
| 396 | printf "\n%-40s: %5s\n" "Developer" "Commits" >> "$LOGFILE" |
| 397 | git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | grep '^Author: ' | \ |
| 398 | sed 's|Author: ||' | sed 's|\s<.*||' | sort | uniq | \ |
| 399 | while read -r line; do |
| 400 | printf "%-40s: %5s %5s\n" "$line" \ |
| 401 | "$(git log "${OLD_GIT_VERSION}" 2>/dev/null | \ |
| 402 | grep -c "^Author: ${line} <")" \ |
| 403 | "$(git log "${NEW_GIT_VERSION}" 2>/dev/null | \ |
| 404 | grep -c "^Author: ${line} <")" >> "$LOGFILE"; |
| 405 | done |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 406 | |
| 407 | printf "\nOld SLOC (%s)\n%s" "$NOW" "$OLD_SLOC" >> "$LOGFILE" |
| 408 | printf "\nNew SLOC (%s)\n%s" "$NOW" "$NEW_SLOC" >> "$LOGFILE" |
| 409 | |
| 410 | # Add the collected data to the top of the existing logfile for parsing |
| 411 | if [ -n "$UPDATE_MAIN_LOGFILE" ]; then |
| 412 | tmpfile="$(mktemp "LOGFILE.XXXX")" |
| 413 | grep -Fxv -f "$MAIN_LOGFILE" "$LOGFILE" > "$tmpfile" |
| 414 | printf "\n\n" >> "$tmpfile" |
| 415 | cat "$MAIN_LOGFILE" >> "$tmpfile" |
| 416 | mv "$tmpfile" "$MAIN_LOGFILE" |
| 417 | rm -f "$LOGFILE" |
| 418 | fi |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 419 | |
| 420 | printf "Done.\n" |