mirror of
https://github.com/tiennm99/ghglance.git
synced 2026-10-15 02:16:50 +00:00
refactor(github): attribute commits by repo language byte share
Each commit now contributes a full "vote" partitioned across the repo's
languages proportional to linguist byte counts, instead of crediting only
the primary language. A 60% Go / 40% Python repo adds 0.6 to Go and 0.4
to Python per commit.
- RepoInfo gains []LangEdge capturing the full byte breakdown already
returned by profileQuery.
- FetchProductive distributes each commit via a fixed-point scaleFactor
(int64 preserved, percentages unchanged in the card).
- Fallback to primary language only when linguist reports zero bytes
(empty repo).
Caveat: linguist excludes prose languages (Markdown, AsciiDoc, reST) from
its byte output, so Markdown-heavy repos still skew toward the detected
code fraction. Fixing that case requires per-commit file classification
via REST /commits/{sha} + go-enry — tracked as future work.
This commit is contained in:
1 parent
9c81926c06
commit
9efb912df5
3 files changed
+68
-15
No files matched your search
@@ -56,6 +56,17 @@ type RepoInfo struct {
|
||||
Name string
|
||||
PrimaryLanguage string
|
||||
PrimaryColor string
|
||||
// Languages is the repo's language byte breakdown as reported by GitHub
|
||||
// linguist. Used to attribute each commit fractionally across all
|
||||
// languages the repo contains, rather than crediting only the primary.
|
||||
Languages []LangEdge
|
||||
}
|
||||
|
||||
// LangEdge is a single entry in a repo's language-bytes breakdown.
|
||||
type LangEdge struct {
|
||||
Name string
|
||||
Color string
|
||||
Bytes int64
|
||||
}
|
||||
|
||||
// repoNode is the GraphQL shape of one repository node; kept here because
|
||||
|
||||
Reference in new issue
Block a user