#!/bin/bash # Usage: ./import-graphics-components.sh [branch] # Default branch is 'main' if not specified. set -e REPO_URL="https://github.com/reuters-graphics/graphics-components.git" REMOTE_NAME="upstreamRepo" SUBTREE_PREFIX="graphics-components-src" BRANCH="${1:-main}" # Remove submodule if present git submodule deinit -f $SUBTREE_PREFIX 2>/dev/null || true git rm -f $SUBTREE_PREFIX 2>/dev/null || true rm -f .gitmodules # Add upstream remote if not present git remote | grep -q "^$REMOTE_NAME$" || git remote add $REMOTE_NAME $REPO_URL git fetch $REMOTE_NAME # Add subtree git subtree add --prefix=$SUBTREE_PREFIX $REMOTE_NAME $BRANCH --squash echo "graphics-components-src imported as a subtree from $REPO_URL ($BRANCH)"