From 8bf2fffa1a6d4d1f0c0b8d9e102fd16a2c3a77df Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 2 Nov 2023 04:36:09 +0000 Subject: [PATCH] feat(git-tag): add HEAD, which is beta as long as any other tags are available --- _common/git-tag.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/_common/git-tag.js b/_common/git-tag.js index aea7592..f987df8 100644 --- a/_common/git-tag.js +++ b/_common/git-tag.js @@ -58,6 +58,18 @@ Repos.getTags = async function (repoPath) { return tags; }; +Repos.getTipInfo = async function (repoPath) { + var { stdout } = await exec( + `git --git-dir=${repoPath} rev-parse --abbrev-ref HEAD`, + ); + var branch = stdout.trim(); + + var info = await Repos.getCommitInfo(repoPath, 'HEAD'); + info.commitish = branch; + + return info; +}; + Repos.getCommitInfo = async function (repoPath, commitish) { var { stdout } = await exec( `git --git-dir=${repoPath} log -1 --format="%h %H %ad %cd" --date=iso-strict ${commitish}`, @@ -107,6 +119,23 @@ async function getAllReleases(gitUrl) { commitInfos.push(commitInfo); } + { + let tipInfo = await Repos.getTipInfo(repoPath); + // "2024-01-01T00:00:00-05:00" => "2024-01-01T05:00:00" + let date = new Date(tipInfo.date); + // "2024-01-01T05:00:00" => "v2024.01.01-05.00.00" + let version = date.toISOString(); + // strip '.000Z' + version = version.replace(/\.\d+Z/, ''); + version = version.replace(/[:\-]/g, '.'); + version = version.replace(/T/, '-'); + Object.assign(tipInfo, { version: `v${version}`, channel: '' }); + if (commitInfos.length > 1) { + tipInfo.channel = 'beta'; + } + commitInfos.push(tipInfo); + } + let releases = []; for (let commitInfo of commitInfos) { let version = commitInfo.version.replace(/^v/, '');