Skip to content
Merged
Prev Previous commit
Next Next commit
fix: add early return for empty tag list in pushTags function
  • Loading branch information
WeslleyNasRocha authored and JounQin committed Apr 1, 2025
commit 322515711fc3093d8ac97fd57de21039a67657b6
29 changes: 17 additions & 12 deletions src/git-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,26 @@ export const push = async (
}

export const pushTags = async () => {
// Get the commit hash
const { stdout: commitHash } = await execWithOutput("git", [
"rev-parse",
"HEAD",
]);
// Get the tags that contain the commit
const { stdout: tags } = await execWithOutput('git', [
'--no-pager',
'tag',
`HEAD`,
])
const { stdout: tags } = await execWithOutput("git", [
"--no-pager",
"tag",
"--contains",
commitHash,
]);
// Separate the tags into a list
const tagList = tags.split('\n')
if (tagList.length > 0) {
// Push the tags individually to the remote
for (const tag of tagList) {
await exec('git', ['push', 'origin', tag])
}
const tagList = tags.split("\n");
// Push the tags individually to the remote
for (const tag of tagList) {
await exec("git", ["push", "origin", tag]);
}
}
};


export const switchToMaybeExistingBranch = async (branch: string) => {
const { stderr } = await execWithOutput('git', ['checkout', branch], {
Expand Down