Page MenuHomeDevCentral

arc-merge-land
No OneTemporary

arc-merge-land

#!/bin/sh
# -------------------------------------------------------------
# Arc merge and land helper
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
# Source file: roles/devserver/userland-home/files/dereckson/bin/arc-merge-land
# -------------------------------------------------------------
#
# <auto-generated>
# This file is managed by our rOPS SaltStack repository.
#
# Changes to this file may cause incorrect behavior
# and will be lost if the state is redeployed.
# </auto-generated>
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 13, 14:48 (3 d, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4222007
Default Alt Text
arc-merge-land (1 KB)

Event Timeline