File: push_auto_update.sh

package info (click to toggle)
mysql-8.0 8.0.43-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,904 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,184; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,196; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (45 lines) | stat: -rwxr-xr-x 1,719 bytes parent folder | download | duplicates (3)
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
#!/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

./regenerate_stale_files.sh

# 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 pull --rebase
git push --force-with-lease || echo "Conflicting commit hit, retrying in next job..."