@windyroad/architect 0.21.2 → 0.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -193,7 +193,8 @@ entry_existed=0
|
|
|
193
193
|
tmp_entry=$(mktemp -t architect-entry.XXXXXX)
|
|
194
194
|
tmp_readme=$(mktemp -t architect-readme.XXXXXX)
|
|
195
195
|
backup_readme=$(mktemp -t architect-readme-orig.XXXXXX)
|
|
196
|
-
|
|
196
|
+
tmp_counts=$(mktemp -t architect-readme-counts.XXXXXX)
|
|
197
|
+
trap 'rm -f "$tmp_entry" "$tmp_readme" "$backup_readme" "$tmp_counts"' EXIT
|
|
197
198
|
cp "$readme" "$backup_readme"
|
|
198
199
|
printf '%s\n' "$new_entry" > "$tmp_entry"
|
|
199
200
|
|
|
@@ -240,6 +241,39 @@ awk -v id="$adr_id" -v section="$target_section" -v entryfile="$tmp_entry" '
|
|
|
240
241
|
END { if (!done) { print ""; print entry } }
|
|
241
242
|
' "$tmp_readme" > "$readme"
|
|
242
243
|
|
|
244
|
+
# Keep the derived aggregate labels aligned with the entry set after an ADR is
|
|
245
|
+
# added or moves between the in-force and historical sections.
|
|
246
|
+
total_count=$(grep -cE '^### ADR-[0-9]+' "$readme")
|
|
247
|
+
inforce_count=$(awk '
|
|
248
|
+
/^## In-force decisions/ { insec=1; next }
|
|
249
|
+
/^## Historical decisions/ { insec=0 }
|
|
250
|
+
insec && /^### ADR-[0-9]+/ { count++ }
|
|
251
|
+
END { print count+0 }
|
|
252
|
+
' "$readme")
|
|
253
|
+
historical_count=$(awk '
|
|
254
|
+
/^## Historical decisions/ { insec=1; next }
|
|
255
|
+
insec && /^### ADR-[0-9]+/ { count++ }
|
|
256
|
+
END { print count+0 }
|
|
257
|
+
' "$readme")
|
|
258
|
+
awk -v total="$total_count" -v inforce="$inforce_count" -v historical="$historical_count" '
|
|
259
|
+
/^\*\*Total ADRs:\*\*/ {
|
|
260
|
+
sub(/[0-9]+ \([0-9]+ in-force, [0-9]+ historical\)/,
|
|
261
|
+
total " (" inforce " in-force, " historical " historical)")
|
|
262
|
+
}
|
|
263
|
+
after_inforce && /^_[0-9]+ ADRs?\./ {
|
|
264
|
+
sub(/^_[0-9]+ ADRs?\./, "_" inforce " ADR" (inforce == 1 ? "" : "s") ".")
|
|
265
|
+
after_inforce=0
|
|
266
|
+
}
|
|
267
|
+
after_historical && /^_[0-9]+ ADRs?\./ {
|
|
268
|
+
sub(/^_[0-9]+ ADRs?\./, "_" historical " ADR" (historical == 1 ? "" : "s") ".")
|
|
269
|
+
after_historical=0
|
|
270
|
+
}
|
|
271
|
+
/^## In-force decisions/ { after_inforce=1 }
|
|
272
|
+
/^## Historical decisions/ { after_historical=1 }
|
|
273
|
+
{ print }
|
|
274
|
+
' "$readme" > "$tmp_counts"
|
|
275
|
+
mv "$tmp_counts" "$readme"
|
|
276
|
+
|
|
243
277
|
# --- Fail-closed post-condition guard (P367, ADR-078 criterion l) -----------
|
|
244
278
|
# The rewrite must preserve every OTHER ADR's entry and the section structure;
|
|
245
279
|
# only the edited ADR's entry may change (it may be newly added). If the result
|