commit e2a22bd643f16bc4ee5869236479e32027d8e40b
parent 48e3e841942836a7785987c30fc26b5e44e53654
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 21 Nov 2021 13:34:03 +0100
hare release: rig up initial changelog bits
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/cmd/hare/release.ha b/cmd/hare/release.ha
@@ -1,10 +1,12 @@
use errors;
use fmt;
+use fs;
use io;
use os::exec;
use os;
use strconv;
use strings;
+use temp;
use unix;
type increment = enum {
@@ -16,7 +18,7 @@ type increment = enum {
type modversion = (uint, uint, uint);
type git_error = !exec::exit_status;
type badversion = !void;
-type release_error = !(exec::error | io::error | errors::error
+type release_error = !(exec::error | io::error | fs::error | errors::error
| badversion | git_error);
fn parseversion(in: str) (modversion | badversion) = {
@@ -65,8 +67,6 @@ fn do_release(incr: increment, dryrun: bool) (void | release_error) = {
defer free(lasttag);
const current = parseversion(lasttag)?;
- fmt::printfln("current version: {}.{}.{}",
- current.0, current.1, current.2)!;
const new: modversion = switch (incr) {
case increment::MAJOR =>
yield (current.0 + 1, 0, 0);
@@ -75,10 +75,20 @@ fn do_release(incr: increment, dryrun: bool) (void | release_error) = {
case increment::PATCH =>
yield (current.0, current.1, current.2 + 1);
};
- fmt::printfln("new version: {}.{}.{}", new.0, new.1, new.2)!;
+ const newtag = fmt::asprintf("{}.{}.{}", new.0, new.1, new.2);
+ defer free(newtag);
const range = fmt::asprintf("{}..HEAD", lasttag);
defer free(range);
- shortlog(os::stdout_file, range)?;
+
+ const dir = temp::dir();
+ defer os::rmdirall(dir)!;
+ const changelog = temp::named(os::cwd, dir, io::mode::WRITE)?;
+ const clfile = changelog.0, changelog = changelog.1;
+ fmt::fprintfln(clfile, "# Version {}", newtag)?;
+ fmt::fprintln(clfile, "# TODO: Fill in more stuff here")?;
+ shortlog(clfile, range)?;
+
+ git_runcmd("tag", "-aeF", changelog, newtag)?;
};
fn do_initial_release() (void | release_error) = {
diff --git a/cmd/hare/subcmds.ha b/cmd/hare/subcmds.ha
@@ -249,6 +249,8 @@ fn release(args: []str) void = {
fmt::fatal(errors::strerror(err));
case err: io::error =>
fmt::fatal(io::strerror(err));
+ case err: fs::error =>
+ fmt::fatal(fs::strerror(err));
case err: git_error =>
fmt::fatal("git: {}", exec::exitstr(err));
case badversion =>