feat: Standardize WORK_DIR and master repository interactions

This commit is contained in:
Matteo Cherubini 2026-06-12 10:49:04 +02:00
parent 1536262acf
commit b48c99b0ff
3 changed files with 15 additions and 10 deletions

View file

@ -30,16 +30,17 @@ setup:
add-genome: add-genome:
@if [ -z "$(NAME)" ] || [ -z "$(DESC)" ]; then \ @if [ -z "$(NAME)" ] || [ -z "$(DESC)" ]; then \
echo "Error: NAME and DESC are required."; \ echo "Error: NAME and DESC are required."; \
echo "Usage: make add-genome NAME=my-genome DESC='My description' [LINKED=owner/project-repo]"; \ echo "Usage: make add-genome NAME=my-genome DESC='My description' [LINKED=owner/project-repo] [CROSS=yes|no]"; \
exit 1; \ exit 1; \
fi fi
@bash scripts/add-genome.sh "$(NAME)" "$(DESC)" "$(LINKED)" @bash scripts/add-genome.sh "$(NAME)" "$(DESC)" "$(LINKED)" "$(or $(CROSS),no)"
status: status:
@[ -d "$(MASTER_REPO)" ] || { echo "Master non trovato. Esegui 'make setup'."; exit 1; }
@echo "--- Master Status ---" @echo "--- Master Status ---"
@git submodule status @cd $(MASTER_REPO) && git submodule status
@echo "--- Encryption Status (per genome) ---" @echo "--- Encryption Status (per genome) ---"
@git submodule foreach 'git-crypt status 2>/dev/null | head -n 10 || true' @cd $(MASTER_REPO) && git submodule foreach 'git-crypt status 2>/dev/null | head -n 10 || true'
verify-structure: verify-structure:
@bash scripts/verify-genomes.sh @bash scripts/verify-genomes.sh
@ -62,14 +63,16 @@ doctor:
@echo "System ready." @echo "System ready."
sync: sync:
@[ -d "$(MASTER_REPO)" ] || { echo "Master non trovato. Esegui 'make setup'."; exit 1; }
@echo "Syncing submodules..." @echo "Syncing submodules..."
@git submodule update --init --recursive @cd $(MASTER_REPO) && git submodule update --init --recursive
@echo "--- Unpushed commits per genome ---" @echo "--- Unpushed commits per genome ---"
@git submodule foreach 'git log --oneline @{u}.. 2>/dev/null | head -5 || true' @cd $(MASTER_REPO) && git submodule foreach 'git log --oneline @{u}.. 2>/dev/null | head -5 || true'
lock: lock:
@[ -d "$(MASTER_REPO)" ] || { echo "Master non trovato. Esegui 'make setup'."; exit 1; }
@echo "Locking master repository..." @echo "Locking master repository..."
@git-crypt lock 2>/dev/null || true @cd $(MASTER_REPO) && git-crypt lock 2>/dev/null || true
@echo "Locking all submodules..." @echo "Locking all submodules..."
@git submodule foreach 'git-crypt lock 2>/dev/null || true' @cd $(MASTER_REPO) && git submodule foreach 'git-crypt lock 2>/dev/null || true'
@echo "All genomes securely locked." @echo "All genomes securely locked."

View file

@ -692,7 +692,9 @@ If a key is lost or compromised:
```bash ```bash
# From the knowledge-genome-orchestrator/ directory # From the knowledge-genome-orchestrator/ directory
source lib/git-crypt.sh source lib/git-crypt.sh
cd ~/knowledge-genome-orchestrator/genome-dev # If gcrypt_rotate_key operates on the CWD: cd into .../master-knowledge-genome/genome-dev
# If it navigates by name instead: cd into .../master-knowledge-genome
cd ~/knowledge-genome-orchestrator/master-knowledge-genome
gcrypt_rotate_key "genome-dev" gcrypt_rotate_key "genome-dev"
``` ```

View file

@ -12,7 +12,7 @@ _REGISTRY_LOADED=1
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Dynamic paths # Dynamic paths
WORK_DIR="${HOME}/knowledge-genome-orchestrator" WORK_DIR="${PROJECT_ROOT}"
KEYS_DIR="${WORK_DIR}/keys" KEYS_DIR="${WORK_DIR}/keys"
TEMPLATES_DIR="${PROJECT_ROOT}/templates" TEMPLATES_DIR="${PROJECT_ROOT}/templates"
LIB_DIR="${PROJECT_ROOT}/lib" LIB_DIR="${PROJECT_ROOT}/lib"