Skip to content

Instantly share code, notes, and snippets.

@ZoomTen
Created January 29, 2025 03:01
Show Gist options
  • Save ZoomTen/a713d3d6e2d0f79e2299456209838d22 to your computer and use it in GitHub Desktop.
Save ZoomTen/a713d3d6e2d0f79e2299456209838d22 to your computer and use it in GitHub Desktop.
Show a timeline of git tag dates
git for-each-ref --format="%(refname:short) %(creatordate:iso8601)" refs/tags > tags.txt
import matplotlib.pyplot as plt
from datetime import datetime
# Sample data
with open("tags.txt", "r") as file:
lines = file.readlines()
# Transform each line
tags = [
(f"{parts[1]}T{parts[2]}{parts[3][0:3]}:{parts[3][3:]}", parts[0])
for line in lines if (parts := line.split())
]
# Process data
dates = [datetime.fromisoformat(tag[0]) for tag in tags]
labels = [tag[1] for tag in tags]
# Plot
plt.figure(figsize=(10, 1))
plt.hlines(1, min(dates), max(dates), colors='lightgray', linewidth=2) # Base line
plt.scatter(dates, [1] * len(dates), color='blue', zorder=5) # Points
# Add labels
for date, label in zip(dates, labels):
plt.text(date, 1.002, label, rotation=90, ha='center', fontsize=9)
plt.gca().get_yaxis().set_visible(False) # Hide Y-axis
plt.xlabel("Time")
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment