Skip to content

Commit

Permalink
feat!: add support for branch filtering on getLastRelease (#265)
Browse files Browse the repository at this point in the history
feat!: add support for branch filtering on getLastRelease

useful for release branche
  • Loading branch information
louis-bompart authored Oct 21, 2024
1 parent 3a15ce7 commit 24237ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import { createAppAuth } from "@octokit/auth-app";
//#endregion

//#region Find current and new versions
const lastTag = await getLastTag(VERSION_PREFIX);
const lastTag = await getLastTag({ prefix: VERSION_PREFIX });
// Passing an empty string allow empty commits (i.e. that does not modify any files) to be included.
const commits = await getCommits("", lastTag);
const parsedCommits = parseCommits(commits, CONVENTION.parserOpts);
Expand Down
8 changes: 7 additions & 1 deletion src/git/getLastGitTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import gitLogger from "./utils/gitLogger.js";
* @param prefix only consider tag that has this prefix. Will return the last tag of the current branch by default.
* @return an array containing the last tag and the process that was spawned
*/
export default async function (prefix?: string): Promise<string> {
export default async function ({
prefix,
onBranch,
}: { prefix?: string; onBranch?: string } = {}): Promise<string> {
const gitParams = ["describe", "--tags", "--abbrev=0"];
if (prefix) {
gitParams.push(`--match=${prefix}*`);
}
if (onBranch) {
gitParams.push(`${onBranch}`);
}
const gitPs = await spawn("git", gitParams, gitLogger);

return gitPs.stdout.trim();
Expand Down

0 comments on commit 24237ac

Please sign in to comment.