Skip to content

Instantly share code, notes, and snippets.

@x0000ff
Last active July 10, 2023 14:10
Show Gist options
  • Save x0000ff/d0023bce5b85dd2f034330fb7a3c78f8 to your computer and use it in GitHub Desktop.
Save x0000ff/d0023bce5b85dd2f034330fb7a3c78f8 to your computer and use it in GitHub Desktop.
Clean local and remote obsolete tags tags

Just run

/usr/bin/swift <(curl -sL https://gist.githubusercontent.com/x0000ff/d0023bce5b85dd2f034330fb7a3c78f8/raw/7f465670da920ef4f6f6c9dc09920ca2c7dcf84d/clean-tags.sh)
#!/usr/bin/swift
import Foundation
main()
func main() {
print("\n\n############################################################################################")
print("DON'T WORRY ABOUT ERRORS. IT'S OKAY")
print("IT MEANS THAT TAG IS NOT EXIST AND IT EXACTLY WHAT WE WANT")
print("############################################################################################\n\n")
let tags = [
"22.04.2022",
"Needs-QA",
"QA-Needed",
"QA_Needed",
"before",
"before-kot",
"before-kot-2",
"before-merge",
"before-merge-13023",
"before-rebase",
"before-rebase-5691",
"before-rebase-ALL",
"before-rebase-kot",
"before-refactoring",
"before-starsview",
"beforeRebase",
"before_rebase",
"doNotDeletePlease",
"draft",
"feature/PQP-2120_no_payment_methods_popup",
"kot-stash",
"kote-before",
"old-part-1",
"old-part-2",
"old_version",
"proposal/Danger",
"resto",
"xxx",
"15113",
"feature/2FA/before-reorganize",
"kot-chino",
"kot-fix",
"kot-xxx",
"old-remote",
"MultipartRemoved"
]
tags.forEach {
print("Deleting tag \"\($0)\"")
shell("git", "tag", "-d", $0) // Delete local tag
// shell("git", "push", "--delete", "origin", $0) // Delete remote tag at "origin"
}
print("\n\n############################################################################################")
print("DON'T WORRY ABOUT ERRORS. IT'S OKAY")
print("IT MEANS THAT TAG IS NOT EXIST AND IT EXACTLY WHAT WE WANT")
print("############################################################################################\n\n")
}
@discardableResult
func shell(_ args: String...) -> Int32 {
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = args
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment