#!/usr/bin/env bash # Fetch (or update) the three repos this deployment is built from. # # scripts/fetch.sh clone/init the submodules, check out and fast-forward branch "sv" in each # scripts/fetch.sh --pinned check out exactly the commits recorded in this repo (detached HEAD) # # Also adds the original DARC repos as the local-only remote "upstream", so upstream changes # can be pulled in with `git fetch upstream`. set -euo pipefail cd "$(dirname "$0")/.." BRANCH=sv declare -A UPSTREAM=( [50ohm]=https://github.com/DARC-e-V/50ohm.git [50ohm-contents-dl]=https://github.com/DARC-e-V/50ohm-contents-dl.git [50ohm-ansible]=https://github.com/DARC-e-V/50ohm-ansible.git ) git submodule sync --quiet git submodule update --init for repo in "${!UPSTREAM[@]}"; do if ! git -C "$repo" remote | grep -qx upstream; then git -C "$repo" remote add upstream "${UPSTREAM[$repo]}" echo "$repo: added remote upstream" fi if [[ "${1:-}" != "--pinned" ]]; then git -C "$repo" fetch --quiet origin git -C "$repo" checkout --quiet "$BRANCH" git -C "$repo" merge --quiet --ff-only "origin/$BRANCH" || echo "$repo: $BRANCH has local commits, not fast-forwarded" fi echo "$repo: $(git -C "$repo" rev-parse --abbrev-ref HEAD) @ $(git -C "$repo" rev-parse --short HEAD)" done [[ -f .env ]] || { cp .env.example .env && echo "created .env from .env.example"; } echo "Done. Next: make build && make up"