Untitled
unknown
python
2 years ago
1.5 kB
12
Indexable
import subprocess
import re
def fetch_matching_remote_tags():
command = ["git", "ls-remote", "--tags", "origin"]
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode != 0:
print("Error fetching tags:", result.stderr)
return []
tag_lines = result.stdout.split('\n')
matching_tags = []
for line in tag_lines:
parts = line.split('\t')
if len(parts) == 2:
tag_name = parts[1].split('/')[-1]
if tag_matches(tag_name):
matching_tags.append(tag_name)
return matching_tags
def tag_matches(tag):
pattern = re.compile(r'^(?P<major>\d+)\.(?P<minor>\d+)\.\d+-rc\.\d+$')
match = pattern.match(tag)
if (match):
major = match.group('major')
minor = match.group('minor')
return int(major) != 5 or int(minor) <= 25
return False
def delete_tags(tags):
for tag in tags:
command = ["git", "push", "--delete", "origin", tag]
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode != 0:
print("Error deleting tag", tag, ":", result.stderr)
else:
print("Deleted tag", tag)
if __name__ == "__main__":
matching_tags = fetch_matching_remote_tags()
print("Matching remote tags:")
for tag in matching_tags:
print(tag)
delete_confirm = input("Do you want to delete (y/n): ")
if (delete_confirm.lower() == "y"):
# delete_tags(matching_tags)
pass
Editor is loading...
Leave a Comment