#!/bin/bash

# update-marl merges the latest changes from the github.com/google/marl into
# third_party/marl. This script copies the change descriptions from the squash
# change into the top merge change, along with a standardized description.
REASON=$1

if [ ! -z "$REASON" ]; then
  REASON="\n$REASON\n"
fi

git subtree pull --prefix third_party/marl https://github.com/google/marl master --squash -m "Update marl"

ALL_CHANGES=`git log -n 1 HEAD^2 | egrep '^(\s{4}[0-9a-f]{9}\s*.*)$'`
HEAD_CHANGE=`echo "$ALL_CHANGES" | egrep '[0-9a-f]{9}' -o -m 1`
LOG_MSG=`echo -e "Update Marl to $HEAD_CHANGE\n${REASON}\nChanges:\n$ALL_CHANGES\n\nCommands:\n    git subtree pull --prefix third_party/marl https://github.com/google/marl master --squash\n\nBug: b/140546382"`
git commit --amend -m "$LOG_MSG"
Add shell script that updates marl.
third_party: Add shell script that updates marl.

I find myself copy and pasting the commands out of the previous change, looking in the squash change for the SHAs and descriptions, and amending the top merge change with all this info. It's tedious.

This script does all of this with a one-liner.

Bug: b/140546382
Change-Id: I2ecfd8074b053cbf6de4001a56bca2ffbaccba42
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41230
Kokoro-Presubmit: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Reviewed-by: Nicolas Capens <51edc787c30f24c4904e8ffbb5523c3a9f7a451d@google.com>
Reviewed-by: Antonio Maiorano <86d87a6550afb6b07035c9743fa181900589f7e0@google.com>
Tested-by: Ben Clayton <1f693eb7158dc33015048c09d6712f74dabddf79@google.com>
