#!/usr/bin/env bash

MAIN_BRANCH="main"
TARGET_BRANCH=$(git branch --show-current)

if [ -z $TARGET_BRANCH ]; then
  echo "Cannot find target branch, are you in a git repo?"
  exit 1
fi

if [ $MAIN_BRANCH == $TARGET_BRANCH ]; then
  echo "You cant merge main into main, silly"
  exit 1
fi

echo "Target branch: $TARGET_BRANCH"
sleep 1

git switch "$MAIN_BRANCH" || exit 1

git cherry-pick "$TARGET_BRANCH" || exit 1

git switch "$TARGET_BRANCH" || exit 1

git merge "$MAIN_BRANCH" || exit 1
