From: patrick-scho Date: Thu, 22 Aug 2024 09:29:13 +0000 (+0200) Subject: new test for frontend X-Git-Url: https://gitweb.ps.run/ziggit/commitdiff_plain/082dd5cd1782d1a384217bcfe309910c4df459b0 new test for frontend --- diff --git a/git.zig b/git.zig index 22bdf5d..27081a2 100644 --- a/git.zig +++ b/git.zig @@ -546,3 +546,27 @@ test "list blobs" { } } } + +test "basic frontend" { + const alloc = std.testing.allocator; + var repo = try Repo.open(alloc, "../imgui/.git"); + defer repo.close(); + + const head = try repo.getHead(); + + var id = head; + + for (0..3) |_| { + if (try repo.getObject(id)) |o| { + defer alloc.free(o.data); + + switch (try o.parse(alloc)) { + .c => |c| { + std.debug.print("commit {x}:\n tree: {x}\n parent: {x}\n author: {s}\n committer: {s}\n message: {s}\n", .{ id, c.tree, c.parent, c.author, c.committer, c.message }); + id = c.parent; + }, + else => {}, + } + } + } +}