refactor: Improve genome submodule setup flow
This commit is contained in:
parent
8d984e2511
commit
01769021fa
1 changed files with 17 additions and 22 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# scripts/setup-genomes.sh
|
# scripts/setup-genomes.sh
|
||||||
# Iterates through the GENOMES registry to provision remote and local repos.
|
# Iterates through the GENOMES registry to provision remote and local repos.
|
||||||
# Handles git-crypt initialization and submodule linking.
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
@ -15,48 +14,44 @@ source "providers/${PROVIDER}.sh"
|
||||||
step "Processing Genome Registry"
|
step "Processing Genome Registry"
|
||||||
|
|
||||||
for entry in "${GENOMES[@]}"; do
|
for entry in "${GENOMES[@]}"; do
|
||||||
# Parse name and description from the array
|
|
||||||
IFS='|' read -r GENOME_NAME GENOME_DESC <<< "$entry"
|
IFS='|' read -r GENOME_NAME GENOME_DESC <<< "$entry"
|
||||||
export GENOME_NAME GENOME_DESC
|
export GENOME_NAME GENOME_DESC
|
||||||
|
|
||||||
info "Processing: ${GENOME_NAME}..."
|
info "Processing: ${GENOME_NAME}..."
|
||||||
|
|
||||||
# 1. Remote Provisioning (Idempotent: skips if exists)
|
# 1. Remote Creation (Idempotent)
|
||||||
provider_create_repo "${GENOME_NAME}" "${GENOME_DESC}" "true"
|
provider_create_repo "${GENOME_NAME}" "${GENOME_DESC}" "true"
|
||||||
|
SSH_URL=$(provider_ssh_url "${GENOME_NAME}")
|
||||||
|
|
||||||
GENOME_PATH="${WORK_DIR}/${MASTER_REPO}/${GENOME_NAME}"
|
GENOME_PATH="${WORK_DIR}/${MASTER_REPO}/${GENOME_NAME}"
|
||||||
|
|
||||||
if [ ! -d "${GENOME_PATH}" ]; then
|
if [ ! -d "${GENOME_PATH}" ]; then
|
||||||
info "Creating local directory and initializing scaffold..."
|
cd "${WORK_DIR}/${MASTER_REPO}"
|
||||||
mkdir -p "${GENOME_PATH}"
|
info "Linking ${GENOME_NAME} as a submodule..."
|
||||||
cd "${GENOME_PATH}"
|
|
||||||
git init
|
|
||||||
|
|
||||||
# IMPORTANT: Initialize git-crypt BEFORE creating sensitive files
|
# 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
|
gcrypt_init
|
||||||
|
|
||||||
# Create directory structure and apply templates
|
|
||||||
scaffold_genome "."
|
scaffold_genome "."
|
||||||
install_precommit_hook "."
|
install_precommit_hook "."
|
||||||
|
|
||||||
# Initial commit and push to remote
|
# Initial genome push
|
||||||
git add .
|
git add .
|
||||||
git commit -m "feat: initial scaffold for ${GENOME_NAME}"
|
git commit -m "feat: initial scaffold and git-crypt init for ${GENOME_NAME}"
|
||||||
|
|
||||||
SSH_URL=$(provider_ssh_url "${GENOME_NAME}")
|
|
||||||
git remote add origin "${SSH_URL}"
|
|
||||||
git push -u origin main
|
git push -u origin main
|
||||||
|
|
||||||
# Export the AES key for the user to back up
|
# Key export and instructions (Fix Obs B)
|
||||||
gcrypt_export_key "${GENOME_NAME}"
|
gcrypt_export_key "${GENOME_NAME}"
|
||||||
|
gcrypt_print_key_instructions "${GENOME_NAME}"
|
||||||
|
|
||||||
# 2. Link as submodule in the Master repository
|
# Return to master to consolidate the submodule addition
|
||||||
cd "${WORK_DIR}/${MASTER_REPO}"
|
cd "${WORK_DIR}/${MASTER_REPO}"
|
||||||
info "Linking ${GENOME_NAME} as a submodule..."
|
|
||||||
git submodule add "${SSH_URL}" "${GENOME_NAME}"
|
|
||||||
git add .gitmodules "${GENOME_NAME}"
|
|
||||||
git commit -m "feat: link submodule ${GENOME_NAME}"
|
|
||||||
else
|
|
||||||
warn "Genome directory '${GENOME_NAME}' already exists. Skipping local setup."
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
success "Genome provisioning completed."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue