fix: consolidate TOML parsing in bootstrap_ops_repos into single python3 call (#586)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
57a177a37d
commit
d190296af1
1 changed files with 11 additions and 22 deletions
|
|
@ -139,40 +139,29 @@ bootstrap_ops_repos() {
|
||||||
for toml in "${DISINTO_DIR}"/projects/*.toml; do
|
for toml in "${DISINTO_DIR}"/projects/*.toml; do
|
||||||
[ -f "$toml" ] || continue
|
[ -f "$toml" ] || continue
|
||||||
|
|
||||||
# Extract project name and ops repo slug from TOML
|
# Extract project name, ops repo slug, repo slug, and primary branch from TOML
|
||||||
local project_name ops_slug primary_branch
|
local project_name ops_slug primary_branch
|
||||||
project_name=$(python3 -c "
|
local _toml_vals
|
||||||
|
_toml_vals=$(python3 -c "
|
||||||
import tomllib, sys
|
import tomllib, sys
|
||||||
with open(sys.argv[1], 'rb') as f:
|
with open(sys.argv[1], 'rb') as f:
|
||||||
cfg = tomllib.load(f)
|
cfg = tomllib.load(f)
|
||||||
print(cfg.get('name', ''))
|
print(cfg.get('name', ''))
|
||||||
" "$toml" 2>/dev/null || true)
|
|
||||||
[ -n "$project_name" ] || continue
|
|
||||||
|
|
||||||
ops_slug=$(python3 -c "
|
|
||||||
import tomllib, sys
|
|
||||||
with open(sys.argv[1], 'rb') as f:
|
|
||||||
cfg = tomllib.load(f)
|
|
||||||
print(cfg.get('ops_repo', ''))
|
print(cfg.get('ops_repo', ''))
|
||||||
" "$toml" 2>/dev/null || true)
|
print(cfg.get('repo', ''))
|
||||||
|
|
||||||
primary_branch=$(python3 -c "
|
|
||||||
import tomllib, sys
|
|
||||||
with open(sys.argv[1], 'rb') as f:
|
|
||||||
cfg = tomllib.load(f)
|
|
||||||
print(cfg.get('primary_branch', 'main'))
|
print(cfg.get('primary_branch', 'main'))
|
||||||
" "$toml" 2>/dev/null || true)
|
" "$toml" 2>/dev/null || true)
|
||||||
|
|
||||||
|
project_name=$(sed -n '1p' <<< "$_toml_vals")
|
||||||
|
[ -n "$project_name" ] || continue
|
||||||
|
ops_slug=$(sed -n '2p' <<< "$_toml_vals")
|
||||||
|
local repo_slug
|
||||||
|
repo_slug=$(sed -n '3p' <<< "$_toml_vals")
|
||||||
|
primary_branch=$(sed -n '4p' <<< "$_toml_vals")
|
||||||
primary_branch="${primary_branch:-main}"
|
primary_branch="${primary_branch:-main}"
|
||||||
|
|
||||||
# Fall back to convention if ops_repo not in TOML
|
# Fall back to convention if ops_repo not in TOML
|
||||||
if [ -z "$ops_slug" ]; then
|
if [ -z "$ops_slug" ]; then
|
||||||
local repo_slug
|
|
||||||
repo_slug=$(python3 -c "
|
|
||||||
import tomllib, sys
|
|
||||||
with open(sys.argv[1], 'rb') as f:
|
|
||||||
cfg = tomllib.load(f)
|
|
||||||
print(cfg.get('repo', ''))
|
|
||||||
" "$toml" 2>/dev/null || true)
|
|
||||||
if [ -n "$repo_slug" ]; then
|
if [ -n "$repo_slug" ]; then
|
||||||
ops_slug="${repo_slug}-ops"
|
ops_slug="${repo_slug}-ops"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue