ReviewOS

zig-utils/zig-bump

--changelog generates CHANGELOG.md but doesn't stage/commit/push it

#2
Closed glennmichael123 opened this 9 days ago ·
9 days ago

src/main.zig:174 hardcodes gitAdd(allocator, io, "build.zig.zon") — only ever stages the version file. When --changelog (or --all, which sets changelog = true) is on, generateChangelog() writes CHANGELOG.md to disk, but the subsequent gitAdd doesn't include it. The resulting commit captures only the version bump, push goes out without the changelog, and CHANGELOG.md sits as an untracked file in the user's working tree.

Source

src/main.zig (v0.1.4, lines ~164–204):

if (config.commit or config.tag or config.push) {
    ...
    if (config.changelog) {
        std.debug.print("Generating changelog...\n", .{});
        generateChangelog(allocator, io, new_version) catch |err| {
            std.debug.print("Warning: Failed to generate changelog: {any}\n", .{err});
        };
    }

    try gitAdd(allocator, io, "build.zig.zon");   // ← only stages the zon file

    if (config.commit) { ... }
    if (config.tag) { ... }
    if (config.push) { ... }
}

And gitAdd at src/main.zig:403 runs git add <single_file>:

fn gitAdd(allocator: std.mem.Allocator, io: std.Io, file_path: []const u8) !void {
    const result = try std.process.run(allocator, io, .{
        .argv = &[_][]const u8{ "git", "add", file_path },
    });
    ...
}

A working stageAll() helper that runs git add . already exists in src/git.zig:58 but is unused.

Reproduction

In any project with a build.zig.zon:

$ bump patch --all
Current version: 0.1.1
New version: 0.1.2
Generating changelog...
Created git commit
Created git tag: v0.1.2
Pushed to remote

$ git log -1 --stat
chore: release v0.1.2

 build.zig.zon | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git status
?? CHANGELOG.md      # left behind, never committed, never pushed

Suggested fix

One-line conditional add after the existing gitAdd:

try gitAdd(allocator, io, "build.zig.zon");
if (config.changelog) {
    try gitAdd(allocator, io, "CHANGELOG.md");
}

Or replace the hardcoded single-file add with the existing stageAll() helper:

try git.stageAll(allocator);

The second form is more future-proof if bump ever updates additional files (e.g. package.json for projects that keep it in sync, or README.md version references).

Environment

  • bump v0.1.4 (release binary, aarch64-macos)
  • macOS Darwin 25.3.0 arm64

Sign in to comment on this issue.