Page MenuHomeDevCentral

arc-merge-land
No OneTemporary

arc-merge-land

#!/bin/sh
if [ $# -ne 1 ]
then
>&2 echo "Usage: $(basename "$0") <branch name>"
exit 1
fi
REMOTE=origin
EXCHANGE_REMOTE=datacube
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
DEFAULT_BRANCH=$(git get-default-branch)
LAND_BRANCH=$1
git fetch --all
# Scenario A. We're on that branch we can rebase, then use arc land
if [ "$CURRENT_BRANCH" = "$LAND_BRANCH" ]; then
git rebase "$DEFAULT_BRANCH" && arc land --onto "$DEFAULT_BRANCH"
exit $?
fi
# Scenario B. Let's try to rebase and push
set -e
git checkout "$LAND_BRANCH"
git rebase "$REMOTE/$DEFAULT_BRANCH"
git checkout "$DEFAULT_BRANCH"
git diff-index --quiet --cached HEAD -- && \
git diff-files --quiet && git pull
git merge --ff "$LAND_BRANCH"
git branch -d "$LAND_BRANCH"
arc amend
git push "$REMOTE" "$DEFAULT_BRANCH"
BRANCH_EXISTS=$(git ls-remote --heads "$EXCHANGE_REMOTE" "refs/heads/$LAND_BRANCH")
test -n "$BRANCH_EXISTS" && git push "$EXCHANGE_REMOTE" --delete "$LAND_BRANCH"

File Metadata

Mime Type
text/x-shellscript
Expires
Fri, Nov 6, 17:06 (4 d, 2 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242005
Default Alt Text
arc-merge-land (965 B)

Event Timeline