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:
@if [ -z "$(NAME)" ] || [ -z "$(DESC)" ]; then \
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; \
fi
@bash scripts/add-genome.sh "$(NAME)" "$(DESC)" "$(LINKED)"
@bash scripts/add-genome.sh "$(NAME)" "$(DESC)" "$(LINKED)" "$(or $(CROSS),no)"
status:
@[ -d "$(MASTER_REPO)" ] || { echo "Master non trovato. Esegui 'make setup'."; exit 1; }
@echo "--- Master Status ---"
@git submodule status
@cd $(MASTER_REPO) && git submodule status
@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:
@bash scripts/verify-genomes.sh
@ -62,14 +63,16 @@ doctor:
@echo "System ready."
sync:
@[ -d "$(MASTER_REPO)" ] || { echo "Master non trovato. Esegui 'make setup'."; exit 1; }
@echo "Syncing submodules..."
@git submodule update --init --recursive
@cd $(MASTER_REPO) && git submodule update --init --recursive
@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:
@[ -d "$(MASTER_REPO)" ] || { echo "Master non trovato. Esegui 'make setup'."; exit 1; }
@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..."
@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."

View file

@ -692,7 +692,9 @@ If a key is lost or compromised:
```bash
# From the knowledge-genome-orchestrator/ directory
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"
```

View file

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