Fingerprint the code
The checker lists the file tree and reads up to 300 code files (4 MB total), largest first. It replaces names and strings with placeholders so renamed code can still match. It hashes each run of 12 tokens and keeps the smallest hash in each window of four. Those hashes are the file’s fingerprints.
total = price * qtyV = V * V0c603dc6, the smallest of the four.Look for clues the repo gives away
Before searching, the repo is asked what it already says about itself: whether GitHub lists it as a fork (and how far it has moved from its parent), its licence, the names in its copyright headers, and the package names in its manifests. Each clue can name a repo worth comparing.
Search GitHub for its most unusual lines
The 8 most distinctive lines of code and the README’s most distinctive sentence go to GitHub’s code search as exact phrases: long lines, no imports or boilerplate, at most 2 from one folder. A line found in a few repos makes each a candidate. A line in 50+ repos is common code; when a folder’s lines turn up in several repos, the most-starred repo of that folder’s name is checked too.
return f"<deep_mapping validator…"6 repos
if __name__ == "__main__":common
_PagerWriter.write(records)only here
Read the candidates and compare
Up to 6 candidate repos are opened. Their file trees are compared first: a file with the same git hash is byte-identical and needs no download. Then up to 60 of each candidate’s files are fetched and fingerprinted the same way. The score is containment: how many of this repo’s fingerprints the candidate also holds. The README and images are compared too: images by git hash, the README by runs of 8 words of its prose, leaving out badges, links, code and licence lines.
Name a source only for whole files
Containment alone would blame any repo that shares a popular helper. So fingerprints that appear in 3 or more of this repo’s own files are set aside as idiom, and a file is credited to a source only when that source holds at least half of what is left, and at least 12 fingerprints of it (8 if the file is byte-identical). Files a fork never changed go to its parent. Lines in 50+ repos, and boilerplate, are counted as common code, unless one older repo of another owner holds most of this repo: then it is a copy of a widely copied project, not common code. When several repos hold the same file, another owner’s, older and more-starred repo wins.
Work out who had it first, and who wrote it
For the strongest shared file, the oldest commit that touched it is found on both sides; if those dates cannot settle it, the repos’ creation dates are used. The earlier side is the origin. The source’s author is named only when one person made at least half of its commits. Finally this repo’s README, NOTICE, CREDITS and LICENSE are read to see whether the source is already credited.
What it cannot see
This finds copied code, README text and images: identical, renamed, reformatted or lightly edited. It misses code rewritten in another style, translated or paraphrased by AI, images a README loads from another site (it counts them), and designs rebuilt to look the same. It only sees what GitHub’s search has indexed, and heavy padding can push a copy under the half-a-file rule. A match says the same code is in two places and the dates say which came first; whether that was allowed depends on the licence and the credit.
