Clean up maintenance scripts (#2550)

- Factor update into a separate script. It's pretty verbose.
- Fetch the base branch for doing comparisons in merge scripts.
- Have uniform error handling for missing `gh`
- Some other consistency between the scripts.
- Turn of `set -x`. Current script messaging is better than that
  gets us.

Example PRs created by these scripts (because testing in prod
is the only testing):
https://github.com/google/iree/pull/2554
https://github.com/google/iree/pull/2555
https://github.com/google/iree/pull/2553
diff --git a/scripts/git/main_to_google.sh b/scripts/git/main_to_google.sh
index 53c2513..980cb3a 100755
--- a/scripts/git/main_to_google.sh
+++ b/scripts/git/main_to_google.sh
@@ -25,47 +25,35 @@
 #   (default "upstream").
 # - Requires that the working directory be clean. Will abort otherwise.
 
-set -x
 set -e
 set -o pipefail
 
 GREEN_COMMIT="${1:-main}"
 
+export UPSTREAM_REMOTE="${UPSTREAM_REMOTE:-upstream}"
 PR_BRANCH="${PR_BRANCH:-main-to-google}"
-UPSTREAM_REMOTE="${UPSTREAM_REMOTE:-upstream}"
 FORK_REMOTE="${FORK_REMOTE:-origin}"
 
-if [[ -n "$(git status --porcelain)" ]]; then
-  echo "Working directory not clean. Aborting"
-  git status
-  exit 1
-fi
-if ! git symbolic-ref -q HEAD; then
-  echo "In a detached HEAD state. Aborting"
-  git status
-  exit 1
-fi
-git checkout main
-git pull "${UPSTREAM_REMOTE?}" main --ff-only
-git submodule update --init
-if [[ -n "$(git status --porcelain)" ]]; then
-  echo "Working directory not clean after sync. Aborting"
-  git status
-  exit 1
-fi
+./scripts/git/git_update.sh main
 if [[ "${GREEN_COMMIT}" != "main" ]]; then
   git checkout "${GREEN_COMMIT?}"
   git submodule update
 fi
+
 git checkout -B "${PR_BRANCH?}"
 git push -f "${FORK_REMOTE?}" "${PR_BRANCH?}"
+
+TITLE="Merge main -> google"
+
+git fetch "${UPSTREAM_REMOTE?}" google
+BODY="$(git log ${UPSTREAM_REMOTE?}/google.. --decorate=no --pretty='format:* %h %<(80,trunc)%s')"
+
 if [[ -z "$(which gh)" ]]; then
   echo "gh not found on path."
   echo "Have you installed the GitHub CLI (https://github.com/cli/cli)?"
-  echo "Cannot create PR. Branch ${BRANCH?} pushed, but aborting."
+  echo "Cannot create PR. Branch ${PR_BRANCH?} pushed, but aborting."
+  echo "You can manually create a PR using the generated body:"
+  echo "${BODY?}"
   exit 1
 fi
-gh pr create \
-    --base google \
-    --title="Merge main -> google" \
-    --body="$(git log google.. --decorate=no --pretty='format:* %h %<(80,trunc)%s')"
+gh pr create --base google --title="${TITLE?}" --body="${BODY?}"