Skip to content

Commit 8db7266

Browse files
committed
f
1 parent 59437b9 commit 8db7266

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/compare_and_fix_refs.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ def main():
5757
files_with_differences = 0
5858
unmatched_files = [] # Track files with unmatched refs
5959

60+
# Track which files exist in current branch
61+
current_files = set()
62+
6063
for md_path in sorted(SRC_DIR.rglob("*.md")):
6164
rel = md_path.relative_to(SRC_DIR).as_posix()
6265
rel_with_src = f"{SRC_DIR.name}/{rel}" # Include src/ prefix for output
6366
files_processed += 1
6467

68+
# Track this file as existing in current branch
69+
current_files.add(rel)
70+
6571
try:
6672
content = md_path.read_text(encoding="utf-8")
6773
except UnicodeDecodeError:
@@ -118,13 +124,21 @@ def main():
118124
except Exception as e:
119125
print(f" ❌ Error fixing refs in {rel_with_src}: {e}")
120126

127+
# Check for files that exist in master refs but not in current branch
128+
for master_file_rel in master_refs.keys():
129+
if master_file_rel not in current_files:
130+
rel_with_src = f"{SRC_DIR.name}/{master_file_rel}"
131+
print(f"🗑️ {rel_with_src} (existed in master but not in current one)")
132+
files_with_differences += 1
133+
unmatched_files.append(rel_with_src)
134+
121135
# Save unmatched files to specified path if requested
122136
if args.files_unmatched_paths and unmatched_files:
123137
try:
124138
unmatched_paths_file = Path(args.files_unmatched_paths)
125139
unmatched_paths_file.parent.mkdir(parents=True, exist_ok=True)
126140
with open(unmatched_paths_file, 'w', encoding='utf-8') as f:
127-
f.write(','.join(unmatched_files))
141+
f.write(','.join(list(set(unmatched_files))))
128142
print(f"📝 Saved {len(unmatched_files)} unmatched file paths to: {unmatched_paths_file}")
129143
except Exception as e:
130144
print(f"❌ Error saving unmatched paths to {args.files_unmatched_paths}: {e}")

0 commit comments

Comments
 (0)