mb/ocp/deltalake: Configure FSP DCI via VPD
[coreboot.git] / util / scripts / update_submodules
blob854a943cb563d9517b189bf2c01097278dad8a93
1 #!/usr/bin/env bash
3 # SPDX-License-Identifier: GPL-2.0-only
5 # Description:
6 # Check all submodules for updates. If there are more than a minimum
7 # number of changes, create a commit to update the submodule to the
8 # new version.
10 export LANG=C
11 export LC_ALL=C
12 export TZ=UTC0
14 min_commits=10
16 TOP=${PWD}
17 SUBMODULES_WITH_UPDATES=0
18 submodule_dirs=$(git submodule foreach pwd | grep -v Entering)
21 echo "Checking submodules..."
22 for submodule in $submodule_dirs; do
23 cd "$submodule" || exit 1
24 initial_commit_id="$(git log --pretty='%h' -n 1)"
25 initial_commit_description="$(git log --pretty='%ci - (%s)' -n 1)"
26 git fetch 2>/dev/null
27 updated_commit_id="$(git log --pretty='%h' -n 1 origin/master)"
28 updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")"
29 if [ "${initial_commit_id}" = "${updated_commit_id}" ]; then
30 # echo "No updates for ${submodule}"
31 continue
33 SUBMODULES_WITH_UPDATES+=1
34 update_count="$(git log --oneline "${initial_commit_id}..${updated_commit_id}" | wc -l)"
35 echo "${update_count} new commits for ${submodule}"
36 if [ "${update_count}" -ge "${min_commits}" ]; then
37 echo "Creating commit to update ${submodule##*/} submodule"
38 git checkout "${updated_commit_id}" > /dev/null 2>&1
39 cd "${TOP}" || exit 1
40 sleep 1
41 git add "${submodule}" > /dev/null 2>&1 || exit 1
42 sleep 1
43 git commit -s -F- > /dev/null 2>&1 <<EOF
44 Update ${submodule##*/} submodule to upstream master
46 Updating from commit id ${initial_commit_id}:
47 $initial_commit_description
49 to commit id ${updated_commit_id}:
50 ${updated_commit_description}
52 This brings in ${update_count} new commits.
53 EOF
54 sleep 1
56 done
58 if [ "${SUBMODULES_WITH_UPDATES}" = "0" ]; then
59 echo "No submodules with any updates."