NEW_BRANCH=$1
SOURCE_BRANCH=$2

generate_create_data() {
  cat <<EOF
{
    "name": "$NEW_BRANCH",
    "target": {
      "hash": "$SOURCE_BRANCH"
    }
}
EOF
}

echo Creating Branch $NEW_BRANCH from $SOURCE_BRANCH
CREATE_URL=https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG/refs/branches
curl -X POST $CREATE_URL \
  --fail --show-error --silent \
  --user modea-integrator:$MODEA_INTEGRATOR_SECRET \
  -H 'content-type: application/json' \
  -d "$(generate_create_data)"



