]> gitweb.ps.run Git - ziggit/commitdiff
new test for frontend
authorpatrick-scho <patrick.schoenberger@posteo.de>
Thu, 22 Aug 2024 09:29:13 +0000 (11:29 +0200)
committerpatrick-scho <patrick.schoenberger@posteo.de>
Thu, 22 Aug 2024 09:29:13 +0000 (11:29 +0200)
git.zig

diff --git a/git.zig b/git.zig
index 22bdf5daab0420333bd0fd461f9bb527b35f3883..27081a2f1184e81650160cebea64a36666c168a5 100644 (file)
--- 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 => {},
+            }
+        }
+    }
+}