#!/bin/bash set -e usage() { echo "usage: dcp-runenv REPODIR RUNDIR" } if [ $# -lt 2 ]; then usage >&2 exit 1 fi repodir="$1" rundir="$2" shift 2 if [ ! -d "$rundir" ]; then mkdir "$rundir"; fi git clone -q "$repodir" "$rundir/repo" for b in "$rundir/repo/.git/refs/remotes/origin"/*; do b="${b##*/}" if [ "$b" = HEAD -o "$b" = master ]; then continue; fi (cd "$rundir/repo"; git branch "$b" "origin/$b") || false done cp -a "$rundir/repo/control" "$rundir" mkdir "$rundir/output"