MCPcopy Index your code
hub / github.com/RustPython/RustPython / _bulk_last_updated

Function _bulk_last_updated

scripts/update_lib/deps.py:1126–1172  ·  view source on GitHub ↗

Get last git commit dates for all paths under Lib/ in one git call. Keys are Lib/-relative paths (e.g. "re/__init__.py", "test/test_os.py", "os.py"), plus directory rollups (e.g. "re", "test/test_zoneinfo"). Returns: Dict mapping Lib/-relative path to date string.

()

Source from the content-addressed store, hash-verified

1124
1125@functools.cache
1126def _bulk_last_updated() -> dict[str, str]:
1127 """Get last git commit dates for all paths under Lib/ in one git call.
1128
1129 Keys are Lib/-relative paths (e.g. "re/__init__.py", "test/test_os.py",
1130 "os.py"), plus directory rollups (e.g. "re", "test/test_zoneinfo").
1131
1132 Returns:
1133 Dict mapping Lib/-relative path to date string.
1134 """
1135 file_map: dict[str, str] = {}
1136 try:
1137 result = subprocess.run(
1138 ["git", "log", "--format=%cd", "--date=short", "--name-only", "--", "Lib/"],
1139 capture_output=True,
1140 text=True,
1141 timeout=30,
1142 )
1143 if result.returncode != 0:
1144 return file_map
1145 except Exception:
1146 return file_map
1147
1148 current_date = None
1149 for line in result.stdout.splitlines():
1150 line = line.strip()
1151 if not line:
1152 continue
1153 # Date lines are YYYY-MM-DD format
1154 if len(line) == 10 and line[4] == "-" and line[7] == "-":
1155 current_date = line
1156 elif current_date and line.startswith("Lib/"):
1157 # Strip "Lib/" prefix to get Lib-relative key
1158 rel = line[4:]
1159 if rel and rel not in file_map:
1160 file_map[rel] = current_date
1161
1162 # Pre-compute directory rollups
1163 dir_map: dict[str, str] = {}
1164 for filepath, date in file_map.items():
1165 parts = filepath.split("/")
1166 for i in range(1, len(parts)):
1167 dirpath = "/".join(parts[:i])
1168 if dirpath not in dir_map or date > dir_map[dirpath]:
1169 dir_map[dirpath] = date
1170
1171 dir_map.update(file_map)
1172 return dir_map
1173
1174
1175@functools.cache

Callers 1

_lookup_last_updatedFunction · 0.85

Calls 9

lenFunction · 0.85
runMethod · 0.45
splitlinesMethod · 0.45
stripMethod · 0.45
startswithMethod · 0.45
itemsMethod · 0.45
splitMethod · 0.45
joinMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected