diff --git a/scripts/import-graphics-components.sh b/scripts/import-graphics-components.sh new file mode 100644 index 0000000..66a08d8 --- /dev/null +++ b/scripts/import-graphics-components.sh @@ -0,0 +1,24 @@ +#!/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)" diff --git a/scripts/update-graphics-components.sh b/scripts/update-graphics-components.sh new file mode 100644 index 0000000..3348171 --- /dev/null +++ b/scripts/update-graphics-components.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Usage: ./update-graphics-components.sh [branch] +# Default branch is 'main' if not specified. +# Add upstream remote and fetch +set -e + +REPO_URL="https://github.com/reuters-graphics/graphics-components.git" +REMOTE_NAME="upstreamRepo" +SUBTREE_PREFIX="graphics-components-src" +BRANCH="${1:-main}" + +git remote | grep -q "^$REMOTE_NAME$" || git remote add $REMOTE_NAME $REPO_URL +git fetch $REMOTE_NAME + +git subtree pull --prefix=$SUBTREE_PREFIX $REMOTE_NAME $BRANCH --squash + +echo "graphics-components-src updated from $REPO_URL ($BRANCH)"