hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 41833914308655b88bcb726d42772bcb9cbb8ff7
parent f1be30f83c4d544589ef693dac08b88abd5872d3
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 22 Nov 2021 09:25:17 +0100

hare release: move tag signing into separate func

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mcmd/hare/release.ha | 58++++++++++++++++++++++++++++++----------------------------
1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/cmd/hare/release.ha b/cmd/hare/release.ha @@ -101,34 +101,7 @@ fn do_release( shortlog(clfile, range)?; git_runcmd("tag", "-aeF", changelog, newtag)?; - - fmt::printfln("Using SSH key {} for release signature.", key)!; - const prefix = fmt::asprintf("--prefix={}-{}/", name, newtag); - defer free(prefix); - const archive = exec::cmd("git", "archive", - "--format=tar.gz", prefix, newtag)?; - const ssh = exec::cmd("ssh-keygen", - "-Y", "sign", "-f", key, "-n", "file")?; - const note = exec::cmd("git", "notes", "add", "-F", "-", newtag)?; - exec::setenv(&note, "GIT_NOTES_REF", "refs/notes/signatures/tar.gz"); - - const pipe1 = unix::pipe()?; - const pipe2 = unix::pipe()?; - exec::addfile(&archive, pipe1.1, os::stdout_file); - exec::addfile(&ssh, pipe1.0, os::stdin_file); - exec::addfile(&ssh, pipe2.1, os::stdout_file); - exec::addfile(&note, pipe2.0, os::stdin_file); - const archive = exec::start(&archive)?; - const ssh = exec::start(&ssh)?; - const note = exec::start(&note)?; - io::close(pipe1.0); - io::close(pipe1.1); - io::close(pipe2.0); - io::close(pipe2.1); - exec::check(&exec::wait(&archive)?)?; - exec::check(&exec::wait(&ssh)?)?; - exec::check(&exec::wait(&note)?)?; - + signtag(name, newtag, key)?; fmt::printfln("Tagged {} version {}. " "Use 'git push --follow-tags' to publish the new release.", name, newtag)!; @@ -259,6 +232,35 @@ fn choosekey() (str | release_error) = { return path; }; +fn signtag(name: str, tag: str, key: str) (void | release_error) = { + fmt::printfln("Using SSH key {} for release signature.", key)!; + const prefix = fmt::asprintf("--prefix={}-{}/", name, tag); + defer free(prefix); + const archive = exec::cmd("git", "archive", + "--format=tar.gz", prefix, tag)?; + const ssh = exec::cmd("ssh-keygen", + "-Y", "sign", "-f", key, "-n", "file")?; + const note = exec::cmd("git", "notes", "add", "-F", "-", tag)?; + exec::setenv(&note, "GIT_NOTES_REF", "refs/notes/signatures/tar.gz"); + + const pipe1 = unix::pipe()?; + const pipe2 = unix::pipe()?; + exec::addfile(&archive, pipe1.1, os::stdout_file); + exec::addfile(&ssh, pipe1.0, os::stdin_file); + exec::addfile(&ssh, pipe2.1, os::stdout_file); + exec::addfile(&note, pipe2.0, os::stdin_file); + const archive = exec::start(&archive)?; + const ssh = exec::start(&ssh)?; + const note = exec::start(&note)?; + io::close(pipe1.0); + io::close(pipe1.1); + io::close(pipe2.0); + io::close(pipe2.1); + exec::check(&exec::wait(&archive)?)?; + exec::check(&exec::wait(&ssh)?)?; + exec::check(&exec::wait(&note)?)?; +}; + fn git_runcmd(args: str...) (void | release_error) = { const cmd = exec::cmd("git", args...)?; const proc = exec::start(&cmd)?;