#!/bin/sh # Cut a task branch and record the branch it came from, so pre-push can open # the PR against the right base. # # scripts/task-branch.sh 359 narrow-single-token # -> task/359-narrow-single-token, parent recorded as the current branch set -eu if [ $# -lt 2 ]; then echo "usage: $0 " >&2 exit 2 fi id=$1 shift slug=$(printf '%s' "$*" | tr '[:upper:] ' '[:lower:]-' | tr -cd 'a-z0-9-') parent=$(git symbolic-ref --short HEAD) branch="task/$id-$slug" git checkout -b "$branch" dir="$(git rev-parse --git-dir)/maven-parent" mkdir -p "$dir" printf '%s\n' "$parent" > "$dir/$(printf '%s' "$branch" | tr '/' '_')" echo "$branch, cut from $parent" echo "Commits on it must end with (V-$id)."