Skip to content

Instantly share code, notes, and snippets.

@WeslyG
Created November 20, 2022 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WeslyG/a431e404f36bf424dea04938da58ba5d to your computer and use it in GitHub Desktop.
Save WeslyG/a431e404f36bf424dea04938da58ba5d to your computer and use it in GitHub Desktop.
Предпоследний тег в гите. The penultimate tag in the git
// creatordate нужен потому что в тегах созданных на ранних версиях гита вполне себе может не быть коммитера!
const gitLastTag = execSync(
`git for-each-ref --count=10 --sort=-creatordate --format='%(refname:short)' refs/tags/release/engine/v*`
);
const lastReleaseTags = gitLastTag
.toString()
.split("\n")
.map(i => i.replace(/'|"/g, ""))
.filter(i => i !== "")
.filter(isReleaseTag);
if (lastReleaseTags[1] == undefined) {
throw Error(`penultimate tag not found in list ${JSON.stringify(lastReleaseTags)}`);
}
console.log(`Found penultimate tag = ${lastReleaseTags[1]}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment