Skip to content

Instantly share code, notes, and snippets.

@mikeNG
Last active May 12, 2023 15:55
Show Gist options
  • Save mikeNG/cf268a0e7ce7d679873e20c53eac4b08 to your computer and use it in GitHub Desktop.
Save mikeNG/cf268a0e7ce7d679873e20c53eac4b08 to your computer and use it in GitHub Desktop.
Upload merge commit to gerrit without pushing all the commits
#!/bin/bash
# SPDX-FileCopyrightText: 2023 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
usage() {
echo "Usage ${0} <remote> <merge_sha> <branch>"
}
# Verify argument count
if [ "${#}" -ne 3 ]; then
usage
exit 1
fi
REMOTE="${1}"
MERGE_SHA="${2}"
BRANCH="${3}"
FIRST_SHA="$(git show -s --pretty=%P ${MERGE_SHA} | cut -d ' ' -f 1)"
SECOND_SHA="$(git show -s --pretty=%P ${MERGE_SHA} | cut -d ' ' -f 2)"
git push "${REMOTE}" "${MERGE_SHA}":refs/for/"${BRANCH}"%base="${FIRST_SHA}",base="${SECOND_SHA}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment