Skip to content

Instantly share code, notes, and snippets.

@Jc2k
Created March 21, 2016 14:05
Show Gist options
  • Save Jc2k/d4a01418f4064d955d1e to your computer and use it in GitHub Desktop.
Save Jc2k/d4a01418f4064d955d1e to your computer and use it in GitHub Desktop.
Find the first tag a file was in and the last tag it was changed in
import subprocess
tags = [
subprocess.check_output(["git", "rev-list", "--max-parents=0", "HEAD"]).strip()
]
tags.extend(
subprocess.check_output(["git", "tag", "-l"]).split(),
)
added = {}
changed = {}
for left, right in zip(tags, tags[1:]):
files = set(subprocess.check_output(
["git", "show", "{}...{}".format(left, right), "--no-commit-id", "-r", "--name-only", "--format=format:"]
).strip().split())
for file in files:
if file not in added:
added[file] = right
changed[file] = right
for file, version in added.items():
print file, version, changed[file]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment