I went ahead and deleted the update_file_list.sh script, because (a) there was no good reason for it to be in a separate script and (b) we now need to handle the well-known types in addition to file_lists.cmake. With this change, we just invoke the staleness tests from the main script to update everything. While I was at it I made a couple small fixes: - Don't skip the update step just because the previous commit was by "Protobuf Team Bot". Copybara commits use this name and we still want to do the auto-update step after them. - Include the CL number in the description if the previous commit came from a CL. PiperOrigin-RevId: 487231324pull/10924/head
parent
9b81aaae58
commit
f1998d91a8
5 changed files with 50 additions and 54 deletions
@ -1,41 +0,0 @@ |
||||
#!/bin/bash |
||||
|
||||
# This script updates the CMake file lists (i.e. src/file_lists.cmake), commits |
||||
# the resulting change, and pushes it. This does not do anything useful when |
||||
# run manually, but should be run by our GitHub action instead. |
||||
|
||||
set -ex |
||||
|
||||
# Exit early if the previous commit was made by the bot. This reduces the risk |
||||
# of a bug causing an infinite loop of auto-generated commits. |
||||
if (git log -1 --pretty=format:'%an' | grep -q "Protobuf Team Bot"); then |
||||
echo "Previous commit was authored by bot" |
||||
exit 0 |
||||
fi |
||||
|
||||
$(dirname -- "$0")/update_file_lists.sh |
||||
|
||||
# Try to determine the most recent pull request number. |
||||
title=$(git log -1 --pretty='%s') |
||||
pr_from_merge=$(echo "$title" | sed -n 's/^Merge pull request #\([0-9]\+\).*/\1/p') |
||||
pr_from_squash=$(echo "$title" | sed -n 's/^.*(#\([0-9]\+\))$/\1/p') |
||||
|
||||
pr="" |
||||
if [ ! -z "$pr_from_merge" ]; then |
||||
pr="$pr_from_merge" |
||||
elif [ ! -z "$pr_from_squash" ]; then |
||||
pr="$pr_from_squash" |
||||
fi |
||||
|
||||
if [ ! -z "$pr" ]; then |
||||
commit_message="Auto-generate CMake file lists after PR #$pr" |
||||
else |
||||
# If we are unable to determine the pull request number, we fall back on this |
||||
# default commit message. Typically this should not occur, but could happen |
||||
# if a pull request was merged via a rebase. |
||||
commit_message="Auto-generate CMake file lists" |
||||
fi |
||||
|
||||
git add -A |
||||
git diff --staged --quiet || git commit -am "$commit_message" |
||||
git push |
@ -1,8 +0,0 @@ |
||||
#!/bin/bash -u |
||||
|
||||
# This script generates file lists from Bazel for CMake. |
||||
|
||||
set -e |
||||
|
||||
bazel build //pkg:gen_src_file_lists |
||||
cp -v bazel-bin/pkg/src_file_lists.cmake src/file_lists.cmake |
@ -0,0 +1,46 @@ |
||||
#!/bin/bash |
||||
|
||||
# This script updates src/file_lists.cmake and the checked-in generated code |
||||
# for the well-known types, commits the resulting changes, and pushes them. |
||||
# This does not do anything useful when run manually, but should be run by our |
||||
# GitHub action instead. |
||||
|
||||
set -ex |
||||
|
||||
# Cd to the repo root. |
||||
cd $(dirname -- "$0") |
||||
|
||||
previous_commit_title=$(git log -1 --pretty='%s') |
||||
|
||||
# Exit early if the previous commit was auto-generated. This reduces the risk |
||||
# of a bug causing an infinite loop of auto-generated commits. |
||||
if (echo "$previous_commit_title" | grep -q "^Auto-generate files"); then |
||||
echo "Previous commit was auto-generated" |
||||
exit 0 |
||||
fi |
||||
|
||||
# Run the staleness tests and use them to update any stale files. |
||||
bazel test //src:cmake_lists_staleness_test || ./bazel-bin/src/cmake_lists_staleness_test --fix |
||||
bazel test //src/google/protobuf:well_known_types_staleness_test || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix |
||||
|
||||
# Try to determine the most recent CL or pull request. |
||||
pr_from_merge=$(echo "$previous_commit_title" | sed -n 's/^Merge pull request #\([0-9]\+\).*/\1/p') |
||||
pr_from_squash=$(echo "$previous_commit_title" | sed -n 's/^.*(#\([0-9]\+\))$/\1/p') |
||||
cl=$(git log -1 --pretty='%b' | sed -n 's/^PiperOrigin-RevId: \([0-9]*\)$/\1/p') |
||||
|
||||
if [ ! -z "$pr_from_merge" ]; then |
||||
commit_message="Auto-generate files after PR #$pr_from_merge" |
||||
elif [ ! -z "$pr_from_squash" ]; then |
||||
commit_message="Auto-generate files after PR #$pr_from_squash" |
||||
elif [ ! -z "$cl" ]; then |
||||
commit_message="Auto-generate files after cl/$cl" |
||||
else |
||||
# If we are unable to determine the CL or pull request number, we fall back |
||||
# on this default commit message. Typically this should not occur, but could |
||||
# happen if a pull request was merged via a rebase. |
||||
commit_message="Auto-generate files" |
||||
fi |
||||
|
||||
git add -A |
||||
git diff --staged --quiet || git commit -am "$commit_message" |
||||
git push |
Loading…
Reference in new issue