https://github.com/charlesrocket/ghext
compact git HEAD hash extractor
https://github.com/charlesrocket/ghext
git sha1 sha256
Last synced: 5 months ago
JSON representation
compact git HEAD hash extractor
- Host: GitHub
- URL: https://github.com/charlesrocket/ghext
- Owner: charlesrocket
- License: bsd-3-clause
- Created: 2024-07-23T06:55:11.000Z (over 1 year ago)
- Default Branch: trunk
- Last Pushed: 2025-02-06T13:58:10.000Z (12 months ago)
- Last Synced: 2025-02-28T12:07:57.326Z (11 months ago)
- Topics: git, sha1, sha256
- Language: Zig
- Homepage: https://charlesrocket.github.io/ghext/
- Size: 70.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - ghext - A small library for extracting head commits from Git repositories. (Misc / Large Language Model)
README
# `ghext`
[](https://github.com/charlesrocket/ghext/actions/workflows/ci.yml)
[](https://codecov.io/gh/charlesrocket/ghext)
Extract the hashes of last commits from `git` repositories with `ghext`.
## Installation
`build.zig.zon`:
```zig
.ghext = .{
.url = "https://github.com/charlesrocket/ghext/archive/refs/tags/0.7.3.tar.gz",
.hash = "ghext-0.7.3-dKaQNz1QAACVOGFjt6xRQR2hwo4u3Wa-hYXdl_hYSVn2",
},
```
## Usage
> [!NOTE]
> `git` binary is not required.
[Example](https://github.com/charlesrocket/xtxf/blob/trunk/build.zig)
### Build system
`build.zig`:
```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`:
```zig
const build_options = @import("build_options");
const VERSION = build_options.version;
```
## Documentation
[API reference](https://charlesrocket.github.io/ghext/)