From cfafcaa25575e00106b68c6c3c1bc7392108a593 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 29 Jan 2021 20:05:10 +0100 Subject: Remove merge script Jenkins already provides a setting for merging a branch into upstream. --- gitmirror-merge.sh | 79 ------------------------------------------------------ 1 file changed, 79 deletions(-) delete mode 100755 gitmirror-merge.sh diff --git a/gitmirror-merge.sh b/gitmirror-merge.sh deleted file mode 100755 index d346602..0000000 --- a/gitmirror-merge.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -MIRROR_REMOTE="gitmirror_remote" -CLONE_URL_PATTERN="file://${PWD}/%s" - -msg() { - echo "==> $1" -} - -msg2() { - echo "--> $1" -} - -deepened_fetch() { - local fetch_spec="$1" - local exclude="$2" - if git fetch "${MIRROR_REMOTE}" "${fetch_spec}" \ - --shallow-exclude="${exclude}"; then - msg2 "Deepen fetch by 1" - git fetch "${MIRROR_REMOTE}" "${fetch_spec}" --deepen=1 - else - msg2 "Shallow request possibly empty, retry with depth=1" - git fetch "${MIRROR_REMOTE}" "${fetch_spec}" --depth=1 - fi -} - -merge_patches() { - if (( $# != 3 )); then - echo "Usage: $0 REPOSITORY REMOTE BRANCH" >&2 - exit 1 - fi - - local repository="$1" - local remote="$2" - local branch="$3" - - if [[ "${remote}" == "${MIRROR_REMOTE}" ]]; then - msg "REMOTE must not be ${MIRROR_REMOTE}" >&2 - exit 1 - fi - - local copy_name="${repository}-patch-${remote}-${branch}" - msg "Create working copy ${copy_name}" - rm -rf "${copy_name}" - mkdir "${copy_name}" - pushd "${copy_name}" > /dev/null - git init - local clone_url - # shellcheck disable=2059 - clone_url="$(printf "${CLONE_URL_PATTERN}" "${repository}")" - git remote add "${MIRROR_REMOTE}" "${clone_url}" - - local patch_branch="patch-for/${branch}" - msg "Fetch patch at ${patch_branch}" - local upstream_branch="${remote}/${branch}" - local remote_upstream_ref="refs/remotes/${upstream_branch}" - deepened_fetch "${patch_branch}" "${remote_upstream_ref}" - - msg "Fetch upstream at ${upstream_branch}" - local local_upstream_ref="refs/remotes/${MIRROR_REMOTE}/${upstream_branch}" - deepened_fetch "${remote_upstream_ref}:${local_upstream_ref}" \ - "refs/heads/${patch_branch}" - - msg "Merge ${patch_branch} into ${upstream_branch}" - git checkout -b "${branch}" --no-track "${local_upstream_ref}" - git merge "${MIRROR_REMOTE}/${patch_branch}" --no-ff \ - -m "Merge branch '${patch_branch}' into ${upstream_branch}" - - msg "Push ${branch} to ${MIRROR_REMOTE}" - git push --force "${MIRROR_REMOTE}" "${branch}:${branch}" - - popd > /dev/null - rm -rf "${copy_name}" -} - -if [[ "$0" == "${BASH_SOURCE[0]}" ]]; then - merge_patches "$@" -fi -- cgit v1.2.3-54-g00ecf