Skip to content

Commit d9c903a

Browse files
authored
Merge pull request #77 from hindermath/codex/fix-source-resolver-home-copy
fix: distinguish source checkout from home runtime
2 parents a2bd540 + a2e7b4e commit d9c903a

5 files changed

Lines changed: 53 additions & 20 deletions

docs/project-statistics.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,26 +484,26 @@ Profil 2 verwendet Git-getrackte Textdateien und sichtbare Git-Aktivitaet. Die W
484484

485485
| Kennzahl / Metric | Wert / Value |
486486
|---|---:|
487-
| Textbasis / Text base | 287564 lines |
487+
| Textbasis / Text base | 287597 lines |
488488
| Textdateien / Text files | 1694 |
489489
| Beobachtbarer Zeitraum / Observable period | 2026-03-31..2026-07-19 |
490490
| Aktivtage / Active days | 67 |
491-
| Relevante Commits / Relevant commits | 450 |
492-
| Zeilen je Aktivtag / Lines per active day | 4292.0 |
491+
| Relevante Commits / Relevant commits | 453 |
492+
| Zeilen je Aktivtag / Lines per active day | 4292.5 |
493493
| Peak-Tag im Fenster / Peak day in window | 2026-07-08 / 40319 |
494494
| Peak-Woche im Fenster / Peak week in window | 2026-07-05 / 121867 |
495495
| Laengste Serie / Longest streak | 24 days |
496496
| Speedup vs. 80 lines/day | 53.7x |
497497
| Speedup vs. 100 lines/day | 42.9x |
498-
| Methodik / Methodology | v2; source `bae64b8ede3b` |
498+
| Methodik / Methodology | v2; source `c9eb10ac4bcb` |
499499

500500
### Artefaktmix / Artifact Mix
501501

502502
```text
503503
Produktiv / Production [....................] 0.0% | 0
504504
Tests [#...................] 2.3% | 6726
505505
Dokumentation / Documentation [#################...] 83.5% | 240137
506-
Skripte / Scripts [###.................] 13.0% | 37427
506+
Skripte / Scripts [###.................] 13.0% | 37460
507507
Konfiguration / Configuration [#...................] 0.9% | 2643
508508
Daten und Medien / Data and media [....................] 0.0% | 0
509509
Sonstiger Text / Other text [#...................] 0.2% | 631
@@ -635,7 +635,7 @@ Die Faktoren vergleichen sichtbare Lieferdichte mit den dokumentierten manuellen
635635
Scale: 0..5000 lines/day
636636
Experienced manual [#...................] 80
637637
Thorsten solo [#...................] 100
638-
Visible repository [#################...] 4292.0
638+
Visible repository [#################...] 4292.5
639639
```
640640

641641
Die gemeinsame Skala vergleicht Referenzen und sichtbare Lieferdichte. Sie schreibt die Git-Aktivitaet keiner Person oder KI pauschal zu.
@@ -661,6 +661,6 @@ DE: Das Fenster beginnt am 2025-07-27 und endet am 2026-07-19. Es enthaelt 67 ak
661661
| 2026-04 | 72825 |
662662
| 2026-05 | 2454 |
663663
| 2026-06 | 49106 |
664-
| 2026-07 | 195025 |
664+
| 2026-07 | 195096 |
665665

666666
<!-- project-statistics-v2:end -->

scripts/lib/resolve-home-baseline-source.ps1

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#Requires -Version 7
22
Set-StrictMode -Version Latest
33

4+
function Test-HBSourceRepository {
5+
[CmdletBinding()]
6+
param([Parameter(Mandatory)][string]$Path)
7+
8+
if (-not (Test-Path -LiteralPath (Join-Path $Path '.git')) -or
9+
-not (Test-Path -LiteralPath (Join-Path $Path 'scripts/sync-home.ps1'))) {
10+
return $false
11+
}
12+
$remote = & git -C $Path remote get-url origin 2>$null
13+
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace([string]$remote)) {
14+
return $false
15+
}
16+
$prefix = & git -C $Path rev-parse --show-prefix 2>$null
17+
$LASTEXITCODE -eq 0 -and
18+
[string]::IsNullOrEmpty([string]$prefix)
19+
}
20+
421
function Resolve-HBSourceRepository {
522
[CmdletBinding()]
623
param(
@@ -12,9 +29,10 @@ function Resolve-HBSourceRepository {
1229
if (Test-Path -LiteralPath $candidate -PathType Leaf) {
1330
$candidate = Split-Path -Parent $candidate
1431
}
32+
$homeRoot = (Resolve-Path -LiteralPath $HOME).Path
1533
while ($candidate) {
16-
if ((Test-Path -LiteralPath (Join-Path $candidate '.git')) -and
17-
(Test-Path -LiteralPath (Join-Path $candidate 'scripts/sync-home.ps1'))) {
34+
if ([IO.Path]::GetFullPath($candidate) -ne $homeRoot -and
35+
(Test-HBSourceRepository -Path $candidate)) {
1836
return $candidate
1937
}
2038
$parent = Split-Path -Parent $candidate
@@ -44,8 +62,7 @@ function Resolve-HBSourceRepository {
4462

4563
foreach ($item in $candidates) {
4664
$path = [IO.Path]::GetFullPath([Environment]::ExpandEnvironmentVariables($item.Path))
47-
if ((Test-Path -LiteralPath (Join-Path $path '.git')) -and
48-
(Test-Path -LiteralPath (Join-Path $path 'scripts/sync-home.ps1'))) {
65+
if (Test-HBSourceRepository -Path $path) {
4966
if ($item.Legacy) {
5067
Write-Warning 'Legacy checkout ~/home-baseline-tmp is deprecated; migrate to ~/home-baseline-source.'
5168
}

scripts/lib/resolve-home-baseline-source.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,53 @@
11
#!/usr/bin/env bash
22

3+
_is_hb_source_repository() {
4+
local candidate="$1"
5+
local remote root candidate_root
6+
[ -e "$candidate/.git" ] && [ -f "$candidate/scripts/sync-home.sh" ] || return 1
7+
remote="$(git -C "$candidate" remote get-url origin 2>/dev/null)" || return 1
8+
[ -n "$remote" ] || return 1
9+
root="$(git -C "$candidate" rev-parse --show-toplevel 2>/dev/null)" || return 1
10+
candidate_root="$(cd -- "$candidate" && pwd -P)" || return 1
11+
[ "$(cd -- "$root" && pwd -P)" = "$candidate_root" ]
12+
}
13+
314
resolve_hb_source_repository() {
415
local start_path="${1:-${BASH_SOURCE[0]}}"
516
local allow_legacy="${2:-0}"
6-
local candidate state_path configured
17+
local candidate state_path configured home_root
18+
19+
home_root="$(cd -- "$HOME" && pwd -P)"
720

821
candidate="$(cd -- "$(dirname -- "$start_path")" 2>/dev/null && pwd -P)" || return 2
922
while [ "$candidate" != "/" ]; do
10-
if [ -e "$candidate/.git" ] && [ -f "$candidate/scripts/sync-home.sh" ]; then
23+
if [ "$candidate" != "$home_root" ] && _is_hb_source_repository "$candidate"; then
1124
printf '%s\n' "$candidate"
1225
return 0
1326
fi
1427
candidate="$(dirname -- "$candidate")"
1528
done
1629

1730
if [ -n "${HOME_BASELINE_SOURCE:-}" ] &&
18-
[ -e "${HOME_BASELINE_SOURCE}/.git" ] &&
19-
[ -f "${HOME_BASELINE_SOURCE}/scripts/sync-home.sh" ]; then
31+
_is_hb_source_repository "$HOME_BASELINE_SOURCE"; then
2032
(cd -- "$HOME_BASELINE_SOURCE" && pwd -P)
2133
return 0
2234
fi
2335

2436
state_path="${HOME}/.home-baseline/source-repository.json"
2537
if [ -f "$state_path" ] && command -v jq >/dev/null 2>&1; then
2638
configured="$(jq -er '.sourcePath | select(type == "string" and length > 0)' "$state_path" 2>/dev/null || true)"
27-
if [ -n "$configured" ] && [ -e "$configured/.git" ] &&
28-
[ -f "$configured/scripts/sync-home.sh" ]; then
39+
if [ -n "$configured" ] && _is_hb_source_repository "$configured"; then
2940
(cd -- "$configured" && pwd -P)
3041
return 0
3142
fi
3243
fi
3344

34-
if [ -e "${HOME}/home-baseline-source/.git" ]; then
45+
if _is_hb_source_repository "${HOME}/home-baseline-source"; then
3546
(cd -- "${HOME}/home-baseline-source" && pwd -P)
3647
return 0
3748
fi
38-
if [ "$allow_legacy" -eq 1 ] && [ -e "${HOME}/home-baseline-tmp/.git" ]; then
49+
if [ "$allow_legacy" -eq 1 ] &&
50+
_is_hb_source_repository "${HOME}/home-baseline-tmp"; then
3951
printf '%s\n' 'WARN: ~/home-baseline-tmp is deprecated; migrate to ~/home-baseline-source.' >&2
4052
(cd -- "${HOME}/home-baseline-tmp" && pwd -P)
4153
return 0

scripts/migrate-level0-source-checkout.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ try {
242242
-OldValue $facts.Root -NewValue $targetPath
243243
Set-HBTextReplacement -Path (Join-Path $HOME '.codex/rules/default.rules') `
244244
-OldValue $facts.Root -NewValue $targetPath
245-
Set-HBJsonProperty -Path (Join-Path $stateDirectory 'sync-state.json') `
245+
Set-HBJsonProperty -Path (Join-Path $stateDirectory 'home-sync-state.json') `
246246
-Name 'sourcePath' -Value $targetPath
247247

248248
if ($Json) { $preview | ConvertTo-Json -Compress } else {

scripts/migrate-level0-source-checkout.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHECK_ONLY=0
99
DRY_RUN=0
1010
FINALIZE=0
1111
JSON=0
12+
YES=0
1213

1314
usage() {
1415
cat <<'USAGE'
@@ -19,6 +20,7 @@ Verwendung / Usage: migrate-level0-source-checkout.sh [OPTIONEN]
1920
--check-only Vollstaendiger Preflight / complete preflight
2021
--dry-run Migration anzeigen / preview migration
2122
--finalize Alten Kompatibilitaetslink entfernen / remove legacy link
23+
--yes Rueckfrage fuer Schreib-/Finalize-Lauf bestaetigen / confirm write/finalize
2224
--json Maschinenlesbaren Status ausgeben / emit JSON status
2325
--help, -h Hilfe anzeigen / show help
2426
USAGE
@@ -31,6 +33,7 @@ while [ $# -gt 0 ]; do
3133
--check-only) CHECK_ONLY=1 ;;
3234
--dry-run) DRY_RUN=1 ;;
3335
--finalize) FINALIZE=1 ;;
36+
--yes) YES=1 ;;
3437
--json) JSON=1 ;;
3538
--help|-h) usage; exit 0 ;;
3639
*) printf 'Unknown argument / Unbekanntes Argument: %s\n' "$1" >&2; exit 2 ;;
@@ -53,4 +56,5 @@ args=(-NoProfile -File "${SCRIPT_DIR}/migrate-level0-source-checkout.ps1" -Targe
5356
[ "$DRY_RUN" -eq 1 ] && args+=(-WhatIf)
5457
[ "$FINALIZE" -eq 1 ] && args+=(-Finalize)
5558
[ "$JSON" -eq 1 ] && args+=(-Json)
59+
[ "$YES" -eq 0 ] || args+=('-Confirm:$false')
5660
exec pwsh "${args[@]}"

0 commit comments

Comments
 (0)