Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

177 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ghext

CI Coverage codecov

Extract the hashes of last commits from git repositories with ghext.

Installation

build.zig.zon:

.ghext = .{
    .url = "https://codeberg.org/charlesrocket/ghext/archive/0.7.7.tar.gz",
    .hash = "ghext-0.7.7-dKaQN5ppAADIXDAgOvVXocflUFqS4w8cYmZXfj-qZTlf",
},

Usage

Note

git binary is not required.

Example

Build system

build.zig:

const Ghext = @import("ghext").Ghext;
const build_options = b.addOptions();

exe.root_module.addOptions("build_options", build_options);
build_options.addOption([]const u8, "version", version(b));

fn version(b: *std.Build) []const u8 {
    const semver = manifest.version;
    var gxt = Ghext.init(std.heap.page_allocator) catch return semver;
    const hash = gxt.hash(Ghext.HashLen.Short, Ghext.Worktree.Checked);
    return b.fmt("{s} {s}", .{ semver, hash });
}

const manifest: struct {
    const Dependency = struct {
        url: []const u8,
        hash: []const u8,
        lazy: bool = false,
    };

    name: enum { APPNAME },
    version: []const u8,
    fingerprint: u64,
    paths: []const []const u8,
    minimum_zig_version: []const u8,
    dependencies: struct {
        ghext: Dependency,
    },
} = @import("build.zig.zon");

main.zig:

const build_options = @import("build_options");
const VERSION = build_options.version;

Documentation

API reference

Contributing

Patches are accepted via Codeberg or e-mail.

About

Compact git HEAD hash extractor

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Sponsor this project

Contributors

Languages