Last active
May 12, 2023 15:55
-
-
Save mikeNG/cf268a0e7ce7d679873e20c53eac4b08 to your computer and use it in GitHub Desktop.
Upload merge commit to gerrit without pushing all the commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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