#!/usr/bin/env bash # ============================================================================= # scripts/setup-genomes.sh # Iterates through the GENOMES registry to provision remote and local repos. # ============================================================================= set -euo pipefail source "lib/output.sh" source "config.env" source "lib/scaffold.sh" source "lib/git-crypt.sh" source "providers/${PROVIDER}.sh" step "Processing Genome Registry" for entry in "${GENOMES[@]}"; do IFS='|' read -r GENOME_NAME GENOME_DESC <<< "$entry" export GENOME_NAME GENOME_DESC info "Processing: ${GENOME_NAME}..." # 1. Remote Creation (Idempotent) provider_create_repo "${GENOME_NAME}" "${GENOME_DESC}" "true" SSH_URL=$(provider_ssh_url "${GENOME_NAME}") GENOME_PATH="${WORK_DIR}/${MASTER_REPO}/${GENOME_NAME}" if [ ! -d "${GENOME_PATH}" ]; then cd "${WORK_DIR}/${MASTER_REPO}" info "Linking ${GENOME_NAME} as a submodule..." # FIX BUG 1: Adding the submodule clones the empty remote repository git submodule add "${SSH_URL}" "${GENOME_NAME}" cd "${GENOME_NAME}" # IMPORTANT: Initialize git-crypt BEFORE creating any files gcrypt_init scaffold_genome "." install_precommit_hook "." # Initial genome push git add . git commit -m "feat: initial scaffold and git-crypt init for ${GENOME_NAME}" git push -u origin main # Key export and instructions (Fix Obs B) gcrypt_export_key "${GENOME_NAME}" gcrypt_print_key_instructions "${GENOME_NAME}" # Return to master to consolidate the submodule addition cd "${WORK_DIR}/${MASTER_REPO}" fi done success "Genome provisioning completed."