MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / check_upstream

Function check_upstream

scripts/audit-license-provenance.py:142–174  ·  view source on GitHub ↗
(key, dirpath, repo, pinned=None, exact_path=None)

Source from the content-addressed store, hash-verified

140 results = {}
141
142 def check_upstream(key, dirpath, repo, pinned=None, exact_path=None):
143 fname, ours = local_license(dirpath)
144 if ours is None:
145 results[key] = ("NO-LOCAL-LICENSE", "")
146 return
147 # 1) exact upstream path (e.g. lz4 lib/LICENSE), at HEAD then pinned
148 if exact_path:
149 for ref in (None, pinned):
150 up = upstream_file(repo, exact_path, ref)
151 if up is not None and up == ours:
152 results[key] = ("IDENTICAL" if ref is None else "IDENTICAL@PINNED",
153 f"{repo}:{exact_path}")
154 return
155 # 2) default-branch detected license
156 up = upstream_default_license(repo)
157 if up is not None and up == ours:
158 results[key] = ("IDENTICAL", f"{repo} (default branch)")
159 return
160 # 3) pinned-commit candidates by filename
161 if pinned:
162 tried = [fname] + [c for c in CANDIDATE_NAMES if c != fname]
163 for cand in tried:
164 up2 = upstream_file(repo, cand, pinned)
165 if up2 is not None and up2 == ours:
166 results[key] = ("IDENTICAL@PINNED", f"{repo}:{cand}@{pinned}")
167 return
168 # 4) HEAD candidates by filename
169 for cand in CANDIDATE_NAMES:
170 up3 = upstream_file(repo, cand)
171 if up3 is not None and up3 == ours:
172 results[key] = ("IDENTICAL", f"{repo}:{cand} (default branch)")
173 return
174 results[key] = ("DIFFERS" if up is not None else "ERROR", f"{repo}")
175
176 # Libraries
177 for rel, (repo, exact) in LIBS.items():

Callers 1

mainFunction · 0.85

Calls 3

local_licenseFunction · 0.85
upstream_fileFunction · 0.85
upstream_default_licenseFunction · 0.85

Tested by

no test coverage detected