<p>Martin Roth has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/20703">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/scripts: Add script to update submodules<br><br>Change-Id: I4e238b539f06ce4031e0e99d26943d226a3c2556<br>Signed-off-by: Martin Roth <martinroth@google.com><br>---<br>A util/scripts/update_submodules<br>1 file changed, 73 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/20703/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/util/scripts/update_submodules b/util/scripts/update_submodules<br>new file mode 100755<br>index 0000000..7a22505<br>--- /dev/null<br>+++ b/util/scripts/update_submodules<br>@@ -0,0 +1,73 @@<br>+#!/bin/bash<br>+<br>+# This file is part of the coreboot project.<br>+#<br>+# Copyright (C) 2017 Google Inc.<br>+#<br>+# This program is free software; you can redistribute it and/or modify<br>+# it under the terms of the GNU General Public License as published by<br>+# the Free Software Foundation; version 2 of the License.<br>+#<br>+# This program is distributed in the hope that it will be useful,<br>+# but WITHOUT ANY WARRANTY; without even the implied warranty of<br>+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>+# GNU General Public License for more details.<br>+#<br>+<br>+# Ddescription:<br>+# Check all submodules for updates.  If there are more than a minimum<br>+# number of changes, create a commit to update the submodule to the<br>+# new version.<br>+<br>+export LANG=C<br>+export LC_ALL=C<br>+export TZ=UTC<br>+<br>+min_commits=10<br>+<br>+TOP=${PWD}<br>+SUBMODULES_WITH_UPDATES=0<br>+submodule_dirs=$(git submodule foreach pwd | grep -v Entering)<br>+<br>+(<br>+echo "Checking submodules..."<br>+for submodule in $submodule_dirs; do<br>+    cd "$submodule" || exit 1<br>+  initial_commit_id="$(git log --pretty='%h' -n 1)"<br>+  initial_commit_description="$(git log --pretty='%ci - (%s)' -n 1)"<br>+ git fetch 2>/dev/null<br>+     updated_commit_id="$(git log --pretty='%h' -n 1 origin/master)"<br>+    updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")"<br>+        if [ "${initial_commit_id}" = "${updated_commit_id}" ]; then<br>+             # echo "No updates for ${submodule}"<br>+               continue<br>+     fi<br>+   SUBMODULES_WITH_UPDATES+=1<br>+   update_count="$(git log --oneline "${initial_commit_id}..${updated_commit_id}" | wc -l)"<br>+ echo "${update_count} new commits for ${submodule}"<br>+        if [ "${update_count}" -ge "${min_commits}" ]; then<br>+              echo "Creating commit to update ${submodule##*/} submodule"<br>+                git checkout "${updated_commit_id}" > /dev/null 2>&1<br>+             cd "${TOP}" || exit 1<br>+              sleep 1<br>+              git add "${submodule}" > /dev/null 2>&1 || exit 1<br>+                sleep 1<br>+              git commit -s -F- > /dev/null 2>&1 <<EOF<br>+Update ${submodule##*/} submodule to upstream master<br>+<br>+Updating from commit id ${initial_commit_id}:<br>+$initial_commit_description<br>+<br>+to commit id ${updated_commit_id}:<br>+${updated_commit_description}<br>+<br>+This brings in ${update_count} new commits.<br>+EOF<br>+              sleep 1<br>+      fi<br>+done<br>+<br>+if [ "${SUBMODULES_WITH_UPDATES}" = "0" ]; then<br>+   echo "No submodules with any updates."<br>+fi<br>+)<br></pre><p>To view, visit <a href="https://review.coreboot.org/20703">change 20703</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/20703"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I4e238b539f06ce4031e0e99d26943d226a3c2556 </div>
<div style="display:none"> Gerrit-Change-Number: 20703 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Martin Roth <martinroth@google.com> </div>