3 # SPDX-License-Identifier: GPL-2.0-only
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
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)"
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}"
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
41 git add
"${submodule}" > /dev
/null
2>&1 ||
exit 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.
58 if [ "${SUBMODULES_WITH_UPDATES}" = "0" ]; then
59 echo "No submodules with any updates."