blob: 854a943cb563d9517b189bf2c01097278dad8a93 (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0-only
# Description:
# Check all submodules for updates. If there are more than a minimum
# number of changes, create a commit to update the submodule to the
# new version.
export LANG=C
export LC_ALL=C
export TZ=UTC0
min_commits=10
TOP=${PWD}
SUBMODULES_WITH_UPDATES=0
submodule_dirs=$(git submodule foreach pwd | grep -v Entering)
(
echo "Checking submodules..."
for submodule in $submodule_dirs; do
cd "$submodule" || exit 1
initial_commit_id="$(git log --pretty='%h' -n 1)"
initial_commit_description="$(git log --pretty='%ci - (%s)' -n 1)"
git fetch 2>/dev/null
updated_commit_id="$(git log --pretty='%h' -n 1 origin/master)"
updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")"
if [ "${initial_commit_id}" = "${updated_commit_id}" ]; then
# echo "No updates for ${submodule}"
continue
fi
SUBMODULES_WITH_UPDATES+=1
update_count="$(git log --oneline "${initial_commit_id}..${updated_commit_id}" | wc -l)"
echo "${update_count} new commits for ${submodule}"
if [ "${update_count}" -ge "${min_commits}" ]; then
echo "Creating commit to update ${submodule##*/} submodule"
git checkout "${updated_commit_id}" > /dev/null 2>&1
cd "${TOP}" || exit 1
sleep 1
git add "${submodule}" > /dev/null 2>&1 || exit 1
sleep 1
git commit -s -F- > /dev/null 2>&1 <<EOF
Update ${submodule##*/} submodule to upstream master
Updating from commit id ${initial_commit_id}:
$initial_commit_description
to commit id ${updated_commit_id}:
${updated_commit_description}
This brings in ${update_count} new commits.
EOF
sleep 1
fi
done
if [ "${SUBMODULES_WITH_UPDATES}" = "0" ]; then
echo "No submodules with any updates."
fi
)
|