summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorAnton Hansson <hansson@google.com>2021-04-08 12:31:04 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-04-08 12:31:04 +0000
commit5092350643215fe3e0acf26bdf743e6442017823 (patch)
tree5c2bd1f813e60481aad11e7f7dfd919b69cf189f /api
parent7ed650cf201135c75461e9762f1c8e597d476be8 (diff)
parenteed7191d86a80cae78992d69b31bd17fdca78a39 (diff)
Merge "Add a tool to dump git SHAs of API changes" am: 457ccf2d32 am: 20deed1e69 am: eed7191d86
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652488 Change-Id: Ia5a1269f650b9c9214a5499f18d1375cf5856b62
Diffstat (limited to 'api')
-rwxr-xr-xapi/dump_api_shas.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/api/dump_api_shas.sh b/api/dump_api_shas.sh
new file mode 100755
index 000000000000..c023b312b471
--- /dev/null
+++ b/api/dump_api_shas.sh
@@ -0,0 +1,56 @@
+#!/bin/bash -e
+# This script dumps the git SHAs of all commits inside api tracking directories.
+# It can used by tools wanting to track API changes, and the primary original
+# purpose is to verify verify all API change SHAs have been tracked by the
+# server-side API-council tools.
+#
+# The only argument is used to specify a git commit range to filter by.
+#
+# Example invocation (API changes between O and P):
+# frameworks/base/api/dump_api_shas.sh origin/oreo-dev..origin/pie-dev
+
+set -o pipefail
+
+eecho() { echo $@ >&2 ; }
+
+if [[ $1 == *..* ]]; then
+ exclude=${1/..*}
+ include=${1/*..}
+else
+ eecho No range or invalid range specified, defaulting to all commits from HEAD.
+ exclude=
+ include=HEAD
+fi
+
+eecho -n building queryview...
+{ source build/envsetup.sh && lunch aosp_arm && m queryview; } >/dev/null 2>&1 \
+ || { eecho failed; exit 1; }
+eecho "done"
+
+# This finds the directories where the dependant java_sdk_libs are defined
+bpdirs=$(
+ bazel query --config=queryview --output=package \
+ 'kind(java_sdk_library, deps(//frameworks/base/api/..., 1))' 2>/dev/null
+ echo frameworks/base/core/api # Not a java_sdk_library.
+ echo frameworks/base/services/api # Not a java_sdk_library.
+)
+
+# Find relevant api subdirectories
+apidirs=$(
+ find $bpdirs -type f -name '*current.txt' -path '*/api/*' \
+ | xargs realpath --relative-to=$(pwd) | xargs dirname | sort | uniq
+)
+
+# Dump sorted SHAs of commits in these directories
+{ for d in $apidirs; do
+ ( cd $d
+ eecho inspecting $d
+ exclude_arg=$(test -n "$exclude" && {
+ git rev-parse -q --verify $exclude > /dev/null && echo "--not $exclude" \
+ || eecho "$d has no revision $exclude, including all commits"; } || true)
+ for f in $(find . -name '*current.txt'); do
+ git --no-pager log --pretty=format:%H --no-merges --follow $include $exclude_arg -- $f
+ echo # No trailing newline with --no-pager
+ done
+ )
+done; } | sort | uniq