AzureUndeadModpack/.forgejo/workflows/scripts/message.py

21 lines
526 B
Python
Raw Normal View History

2024-03-21 14:50:54 -04:00
import re
import sys
from typing import Optional
pattern = r"^(?:V|v)ersion\ bump(?:ed)?\ to\ ([0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z0-9]+)?).*"
def get_commit_message(string) -> Optional[str]:
m = re.match(pattern, string)
if m:
return m.group(1)
else:
return None
if __name__ == "__main__":
if len(sys.argv) >= 2:
commit_message = sys.argv[1]
result = get_commit_message(commit_message)
print(result)
else:
print("Usage: python message.py <commit_message>")