Skip to content

Commit

Permalink
delete old branches up to history size
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomatsubara committed May 23, 2024
1 parent c729629 commit b5bc101
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dist/create-release-branch-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24854,7 +24854,8 @@ async function main(input) {
const refsRaw = sh(`git for-each-ref --format='%(refname)' --sort=authordate ${refsPattern}`, { cwd: repo });
const refs = refsRaw.split("\n");
if (refs.length >= input.dryRunHistorySize) {
sh(`git push origin --delete ${refs.at(0)}`, { cwd: repo });
const toDelete = refs.slice(0, refs.length - input.dryRunHistorySize);
toDelete.forEach((ref) => sh(`git push origin --delete ${ref}`, { cwd: repo }));
}
}
sh(`git switch --force-create ${branch}`, { cwd: repo });
Expand Down
3 changes: 2 additions & 1 deletion src/create-release-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export async function main(input: Input) {
const refs = refsRaw.split("\n");

if (refs.length >= input.dryRunHistorySize) {
sh(`git push origin --delete ${refs.at(0)}`, { cwd: repo });
const toDelete = refs.slice(0, refs.length - input.dryRunHistorySize);
toDelete.forEach((ref) => sh(`git push origin --delete ${ref}`, { cwd: repo }));
}
}

Expand Down

0 comments on commit b5bc101

Please sign in to comment.