Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
EXCLUDE_REPOS: ${{ secrets.EXCLUDE_REPOS }}
EXCLUDE_LANGS: ${{ secrets.EXCLUDE_LANGS }}
EXCLUDE_PRIVATE: "false"
EXCLUDE_INHERITED: "true"
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description frames EXCLUDE_INHERITED as an opt-in flag, but the repo workflow sets EXCLUDE_INHERITED: "true" unconditionally, which changes the default generated stats behavior for this repo (and for anyone copying the workflow). Consider omitting this env var by default, or sourcing it from a secret/input and defaulting to "false".

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually wonder if the variable should be set by default to "true' in the code itself. The inflated statistics can be drastic with only a small contribution to a popular repository.

SILENT: "true"
# TODO: Remove this when they get their API working again
# https://github.com/orgs/community/discussions/192970
Expand Down
4 changes: 4 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const Args = struct {
exclude_repos: ?[]const u8 = null,
exclude_langs: ?[]const u8 = null,
exclude_private: bool = false,
exclude_inherited: bool = false,
overview_output_file: ?[]const u8 = null,
languages_output_file: ?[]const u8 = null,
overview_template: ?[]const u8 = null,
Expand Down Expand Up @@ -274,6 +275,9 @@ pub fn main(init: std.process.Init) !void {
{
continue;
}
const is_owned = !repository.fork and
std.mem.eql(u8, repository.owner_login, stats.user);
if (args.exclude_inherited and !is_owned) continue;
aggregate_stats.stars += repository.stars;
aggregate_stats.forks += repository.forks;
aggregate_stats.lines_changed += repository.lines_changed;
Expand Down
9 changes: 9 additions & 0 deletions src/statistics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ const Repository = struct {
lines_changed: u32,
views: u32,
private: bool,
fork: bool,
owner_login: []const u8,

pub fn deinit(self: @This(), allocator: std.mem.Allocator) void {
allocator.free(self.name);
allocator.free(self.owner_login);
Comment on lines +25 to +30
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repository gained new required fields (fork, owner_login). Statistics.initFromJson uses std.json.parseFromSliceLeaky(Statistics, ...), so older JSON files that don't include these fields will now fail to parse. Consider making these fields optional (or providing safe defaults) and updating deinit/aggregation logic accordingly so JSON input remains backwards-compatible.

Suggested change
fork: bool,
owner_login: []const u8,
pub fn deinit(self: @This(), allocator: std.mem.Allocator) void {
allocator.free(self.name);
allocator.free(self.owner_login);
fork: bool = false,
owner_login: ?[]const u8 = null,
pub fn deinit(self: @This(), allocator: std.mem.Allocator) void {
allocator.free(self.name);
if (self.owner_login) |owner_login| {
allocator.free(owner_login);
}

Copilot uses AI. Check for mistakes.
if (self.languages) |languages| {
for (languages) |language| {
language.deinit(allocator);
Expand Down Expand Up @@ -264,6 +267,8 @@ fn getReposByYear(
\\ stargazerCount
\\ forkCount
\\ isPrivate
\\ isFork
\\ owner { login }
\\ languages(
\\ first: 100,
\\ orderBy: { direction: DESC, field: SIZE }
Expand Down Expand Up @@ -320,6 +325,8 @@ fn getReposByYear(
stargazerCount: u32,
forkCount: u32,
isPrivate: bool,
isFork: bool,
owner: struct { login: []const u8 },
languages: ?struct {
edges: ?[]struct {
size: u32,
Expand Down Expand Up @@ -388,9 +395,11 @@ fn getReposByYear(
}
var repository = Repository{
.name = try context.allocator.dupe(u8, raw_repo.nameWithOwner),
.owner_login = try context.allocator.dupe(u8, raw_repo.owner.login),
.stars = raw_repo.stargazerCount,
.forks = raw_repo.forkCount,
.private = raw_repo.isPrivate,
.fork = raw_repo.isFork,
.languages = null,
.views = 0,
.lines_changed = 0,
Expand Down
Loading