From 68aba4992e72a47cc5e0dbb0704d0f3b5cfd8cce Mon Sep 17 00:00:00 2001 From: Jim Fitzpatrick Date: Sat, 30 May 2026 15:26:26 +0100 Subject: [PATCH] UPDATE: Change log management The change log manager has being changed to use changie Signed-off-by: Jim Fitzpatrick --- .changes/0.10.0.md | 19 ++++ .changes/0.7.0.md | 22 +++++ .changes/0.8.0.md | 15 ++++ .changes/0.9.0.md | 19 ++++ .changes/header.tpl.md | 6 ++ {changelog.d => .changes/unreleased}/.gitkeep | 0 .../unreleased/Changed-20260530-152603.yaml | 3 + .changie.yaml | 26 ++++++ .github/workflows/workflow.yaml | 17 ++-- CHANGELOG.md | 35 ++++---- README.md | 25 ++++-- build.zig | 89 ++++++++++++------- build.zig.zon | 20 +++++ changelog.d/70.bugfix.md | 1 - towncrier.toml | 30 ------- 15 files changed, 229 insertions(+), 98 deletions(-) create mode 100644 .changes/0.10.0.md create mode 100644 .changes/0.7.0.md create mode 100644 .changes/0.8.0.md create mode 100644 .changes/0.9.0.md create mode 100644 .changes/header.tpl.md rename {changelog.d => .changes/unreleased}/.gitkeep (100%) create mode 100644 .changes/unreleased/Changed-20260530-152603.yaml create mode 100644 .changie.yaml delete mode 100644 changelog.d/70.bugfix.md delete mode 100644 towncrier.toml diff --git a/.changes/0.10.0.md b/.changes/0.10.0.md new file mode 100644 index 0000000..df8ea11 --- /dev/null +++ b/.changes/0.10.0.md @@ -0,0 +1,19 @@ +## git-grab 0.10.0 (2026-05-30) + +### Features + +- Add parsing to match the CodeBerg ssh clone string format. (#53) +- Zig 0.16.0 + Add support for zig 0.16.0 (#63) +- Allow the shallow clone of repos, forces a depth of one, by setting the `-S/--shallow` flag. (#68) + +### Removals + +- Support for windows. + Saddly to support windows is going to take more effort. That effort is not currently justified. + +### Misc + +- Updated the build system to make use of the zon file reading. (#51) +- Update precommit configuration to include running zig test at commit time +- Updated the towncrier configuration to allows show the contains of the misc fragments. diff --git a/.changes/0.7.0.md b/.changes/0.7.0.md new file mode 100644 index 0000000..c73f10f --- /dev/null +++ b/.changes/0.7.0.md @@ -0,0 +1,22 @@ +## git-grab 0.7.0 (2025-03-22) + +### Features + +- Update the version display to use built in features (#18) +- Configuration of MyPy, now there is strict types (#26) + +### Bugfixes + +- Fix fetch on origin not being configured during the initial setup (#23) + +### Improved Documentation + +- Configure towncrier for the changelog (#12) + +### Deprecations and Removals + +- Remove support for python 3.8 (#20) + +### Misc + +- #13, #14, #19 diff --git a/.changes/0.8.0.md b/.changes/0.8.0.md new file mode 100644 index 0000000..bbdf049 --- /dev/null +++ b/.changes/0.8.0.md @@ -0,0 +1,15 @@ +## git-grab 0.8.0 (2026-01-24) + +### Features + +- Toggle from worktrees to standard clone + + Allow the user with the `-s` to switch from a worktree configuration clone to a standard clone. (#15) +- Zig Port + + This version of git grab moves the python based version to a zig version. (#41) +- Configure towncrier for zig project (#42) + +### Misc + +- #25, #43 diff --git a/.changes/0.9.0.md b/.changes/0.9.0.md new file mode 100644 index 0000000..cce5b8e --- /dev/null +++ b/.changes/0.9.0.md @@ -0,0 +1,19 @@ +## git-grab 0.9.0 (2026-01-31) + +### Features + +- Adding of logger. + All user facing massages are now logs that go to standard error. + The level of these logs can be adjusted as required, with the default level being info. + To do this the `--log-level` flag has being added. (#45) + +### Bugfixes + +- Unhandled error was found when the clone path had an existing non worktree project. + A fatal crash would happen due to the `.git` existing. + This is now handled gracefully. + +### Misc + +- Change data structure for towncrier +- Rework the release system. Now calling `zig build release` will build the cross-platform resources. diff --git a/.changes/header.tpl.md b/.changes/header.tpl.md new file mode 100644 index 0000000..4a78366 --- /dev/null +++ b/.changes/header.tpl.md @@ -0,0 +1,6 @@ +# Changelog git-grab +All notable changes to [git-grab](https://github.com/Boomatang/git-grab/releases) will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). diff --git a/changelog.d/.gitkeep b/.changes/unreleased/.gitkeep similarity index 100% rename from changelog.d/.gitkeep rename to .changes/unreleased/.gitkeep diff --git a/.changes/unreleased/Changed-20260530-152603.yaml b/.changes/unreleased/Changed-20260530-152603.yaml new file mode 100644 index 0000000..4c0c22b --- /dev/null +++ b/.changes/unreleased/Changed-20260530-152603.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: Changelog manager has been changed to use changie. +time: 2026-05-30T15:26:03.560060514+01:00 diff --git a/.changie.yaml b/.changie.yaml new file mode 100644 index 0000000..7022e56 --- /dev/null +++ b/.changie.yaml @@ -0,0 +1,26 @@ +changesDir: .changes +unreleasedDir: unreleased +headerPath: header.tpl.md +changelogPath: CHANGELOG.md +versionExt: md +versionFormat: '## git-grab {{.Version}} ({{.Time.Format "2006-01-02"}})' +kindFormat: '### {{.Kind}}' +changeFormat: '- {{.Body}}' +kinds: + - label: Added + auto: minor + - label: Changed + auto: major + - label: Deprecated + auto: minor + - label: Removed + auto: major + - label: Fixed + auto: patch + - label: Security + auto: patch +newlines: + afterChangelogHeader: 1 + beforeChangelogVersion: 1 + endOfVersion: 1 +envPrefix: CHANGIE_ diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index b94eff9..a24459d 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -48,18 +48,15 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 0 - name: Ensure base branch exists run: git fetch origin ${{ github.base_ref }} - - name: Set up python - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - - name: Install dependencies - run: python -m pip install towncrier - - name: Check new fragment exists - run: towncrier check --compare-with "origin/${{ github.base_ref }}" + run: | + if [ -z "$(git diff --name-only --diff-filter=A "origin/${{ github.base_ref }}" -- '.changes/unreleased/*.yaml')" ]; then + echo "No changelog fragment found in .changes/unreleased/" + echo "Run 'zig build changie:add' to create one." + exit 1 + fi diff --git a/CHANGELOG.md b/CHANGELOG.md index f1f2e24..cabce66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,48 +1,54 @@ -# git-grab 0.10.0 (2026-05-30) +# Changelog git-grab +All notable changes to [git-grab](https://github.com/Boomatang/git-grab/releases) will be documented in this file. -## Features +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). + + +## git-grab 0.10.0 (2026-05-30) + +### Features - Add parsing to match the CodeBerg ssh clone string format. (#53) - Zig 0.16.0 Add support for zig 0.16.0 (#63) - Allow the shallow clone of repos, forces a depth of one, by setting the `-S/--shallow` flag. (#68) -## Removals +### Removals - Support for windows. Saddly to support windows is going to take more effort. That effort is not currently justified. -## Misc +### Misc - Updated the build system to make use of the zon file reading. (#51) - Update precommit configuration to include running zig test at commit time - Updated the towncrier configuration to allows show the contains of the misc fragments. +## git-grab 0.9.0 (2026-01-31) -# git-grab 0.9.0 (2026-01-31) - -## Features +### Features - Adding of logger. All user facing massages are now logs that go to standard error. The level of these logs can be adjusted as required, with the default level being info. To do this the `--log-level` flag has being added. (#45) -## Bugfixes +### Bugfixes - Unhandled error was found when the clone path had an existing non worktree project. A fatal crash would happen due to the `.git` existing. This is now handled gracefully. -## Misc +### Misc - Change data structure for towncrier - Rework the release system. Now calling `zig build release` will build the cross-platform resources. +## git-grab 0.8.0 (2026-01-24) -# git-grab 0.8.0 (2026-01-24) - -## Features +### Features - Toggle from worktrees to standard clone @@ -52,12 +58,11 @@ This version of git grab moves the python based version to a zig version. (#41) - Configure towncrier for zig project (#42) -## Misc +### Misc - #25, #43 - -# Git_Grab 0.7.0 (2025-03-22) +## git-grab 0.7.0 (2025-03-22) ### Features diff --git a/README.md b/README.md index 5fdb6fc..2042cc7 100644 --- a/README.md +++ b/README.md @@ -99,22 +99,29 @@ All matching is case-sensitive, which can be problematic when adding remotes. ### Creating the changelog On new changes a news fragment is required. -This can be created by and news fragments to the `changes` directory. -These files are should have the following naming schema `.`. -Using `towncrier create -c "change message" ` will also create the file for you in the correct location. +Create one interactively with: +``` +zig build changie:add +``` +This places a YAML fragment in `.changes/unreleased/`. +The available change kinds are: `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`. ### Release workflow 1. Ensure the version in `build.zig.zon` is correct for this release. -2. Generate the changelog for the release (review it before proceeding): +2. Batch the unreleased fragments into a versioned changelog file: +``` +zig build changie:batch +``` +3. Review the generated file in `.changes/` for the release version. +4. Merge all versioned changelogs into `CHANGELOG.md`: ``` -zig build changelog_release +zig build changie:merge ``` -3. Review the contents of `CHANGELOG.md` for the release version. -4. Commit changes -5. Build release artifacts: +5. Commit changes. +6. Build release artifacts: ``` zig build release ``` -6. Create a GitHub release for the current commit with the release version as the tag. +7. Create a GitHub release for the current commit with the release version as the tag. - Release notes should be the changelog entry for that version. - Attach all artifacts from `dist/` to the GitHub release. diff --git a/build.zig b/build.zig index 6769998..e5e3b6f 100644 --- a/build.zig +++ b/build.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const zon = @import("build.zig.zon"); // Although this function looks imperative, it does not perform the build // directly and instead it mutates the build graph (`b`) that will be then @@ -25,7 +26,6 @@ pub fn build(b: *std.Build) void { const options = b.addOptions(); // Read version and name form build.zig.zon - const zon = @import("build.zig.zon"); const name_str = @tagName(zon.name); const version = zon.version; @@ -161,25 +161,6 @@ pub fn build(b: *std.Build) void { test_step.dependOn(&run_mod_tests.step); test_step.dependOn(&run_exe_tests.step); - const changelog_cmd = b.addSystemCommand(&.{ - "towncrier", - "build", - "--draft", - "--version", - version, - }); - const changelog_step = b.step("changelog_draft", "Build changelog draft"); - changelog_step.dependOn(&changelog_cmd.step); - - const changelog_release_cmd = b.addSystemCommand(&.{ - "towncrier", - "build", - "--version", - version, - }); - const changelog_release_step = b.step("changelog_release", "Build changelog release"); - changelog_release_step.dependOn(&changelog_release_cmd.step); - const release_step = b.step("release", "Build release archives"); const release_checks = ReleaseChecksStep.create(b, version); @@ -262,6 +243,40 @@ pub fn build(b: *std.Build) void { // // Lastly, the Zig build system is relatively simple and self-contained, // and reading its source code will allow you to master it. + + // Set Up Changie Commands + // WARNING: build() returns early here if changie deps are not fetched. + // Do NOT add build steps after the changie block — they will be silently hidden. + const changie_bin = get_changie_bin(b) orelse return; + + // Changie Add + const changie_add = std.Build.Step.Run.create(b, "run changie"); + changie_add.addFileArg(changie_bin); + changie_add.addArg("new"); + const changie_add_cmd = b.step("changie:add", "Add change log fragment"); + changie_add_cmd.dependOn(&changie_add.step); + + // Changie batch + const changie_batch = std.Build.Step.Run.create(b, "run changie"); + changie_batch.addFileArg(changie_bin); + changie_batch.addArg("batch"); + changie_batch.addArg(zon.version); + const changie_batch_cmd = b.step("changie:batch", "Batch fragments for a release"); + changie_batch_cmd.dependOn(&changie_batch.step); + + // Changie merge + const changie_merge = std.Build.Step.Run.create(b, "run changie"); + changie_merge.addFileArg(changie_bin); + changie_merge.addArg("merge"); + const changie_merge_cmd = b.step("changie:merge", "Merge all changes into CHANGELOG.md"); + changie_merge_cmd.dependOn(&changie_merge.step); + + // Changie Version + const changie_version = std.Build.Step.Run.create(b, "run changie"); + changie_version.addFileArg(changie_bin); + changie_version.addArg("--version"); + const changie_version_cmd = b.step("changie:version", "Print the changie version"); + changie_version_cmd.dependOn(&changie_version.step); } const ReleaseTarget = struct { @@ -341,18 +356,26 @@ fn addReleaseExecutable( return exe; } -fn parseVersionFromZon(zon: []const u8) []const u8 { - const needle = ".version = \""; - if (std.mem.indexOf(u8, zon, needle)) |start| { - const version_start = start + needle.len; - if (std.mem.indexOfPos(u8, zon, version_start, "\"")) |end| { - return zon[version_start..end]; - } - } - - return "unknown"; -} +fn get_changie_bin(b: *std.Build) ?std.Build.LazyPath { + const host = b.graph.host.result; + const name = switch (host.os.tag) { + .linux => switch (host.cpu.arch) { + .x86_64 => "changie_linux_amd64", + .aarch64 => "changie_linux_arm64", + else => return null, + }, + .macos => switch (host.cpu.arch) { + .x86_64 => "changie_darwin_amd64", + .aarch64 => "changie_darwin_arm64", + else => return null, + }, + + else => return null, + }; -fn changelogDraft() void { - std.debug.print("works", .{}); + if (b.lazyDependency(name, .{})) |dep| { + return dep.path("changie"); + } else { + return null; + } } diff --git a/build.zig.zon b/build.zig.zon index be9917d..1fa9c41 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -36,6 +36,26 @@ .url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.12.0.tar.gz", .hash = "clap-0.12.0-oBajB7foAQDqlSwaSG5g0yq7xGbQARUsBk5T64gAOqP5", }, + .changie_linux_amd64 = .{ + .url = "https://github.com/miniscruff/changie/releases/download/v1.24.0/changie_1.24.0_linux_amd64.tar.gz", + .hash = "N-V-__8AAENZjwAgVC77qCVBXAtYm4fnrTMT1RBqj1t8NhBZ", + .lazy = true, + }, + .changie_linux_arm64 = .{ + .url = "https://github.com/miniscruff/changie/releases/download/v1.24.0/changie_1.24.0_linux_arm64.tar.gz", + .hash = "N-V-__8AAENJhwD2wvDEhjJfTloiHqn-qpmoePGSFu-Vx3SJ", + .lazy = true, + }, + .changie_darwin_amd64 = .{ + .url = "https://github.com/miniscruff/changie/releases/download/v1.24.0/changie_1.24.0_darwin_amd64.tar.gz", + .hash = "N-V-__8AAGs5kgBBv5ttmT4sx1a5kaIdXaCpiezGwNPiIjQJ", + .lazy = true, + }, + .changie_darwin_arm64 = .{ + .url = "https://github.com/miniscruff/changie/releases/download/v1.24.0/changie_1.24.0_darwin_arm64.tar.gz", + .hash = "N-V-__8AAC38iQDlMJ83w1JhoVxWE-rVPQK7wL7bP_-5M0EF", + .lazy = true, + }, }, .paths = .{ "build.zig", diff --git a/changelog.d/70.bugfix.md b/changelog.d/70.bugfix.md deleted file mode 100644 index 289122a..0000000 --- a/changelog.d/70.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -Failing to clone a repo when looping over a list of repos does not cause the process to exit early. The process will still exit with a nonzero and the error will be logged. diff --git a/towncrier.toml b/towncrier.toml deleted file mode 100644 index 06f7dcf..0000000 --- a/towncrier.toml +++ /dev/null @@ -1,30 +0,0 @@ -[tool.towncrier] -name = "git-grab" - -filename = "CHANGELOG.md" -directory = "changelog.d" - -[[tool.towncrier.type]] -directory = "feature" -name = "Features" -showcontent = true - -[[tool.towncrier.type]] -directory = "bugfix" -name = "Bugfixes" -showcontent = true - -[[tool.towncrier.type]] -directory = "doc" -name = "Improved Documentation" -showcontent = true - -[[tool.towncrier.type]] -directory = "removal" -name = "Removals" -showcontent = true - -[[tool.towncrier.type]] -directory = "misc" -name = "Misc" -showcontent = true