Page MenuHomePhabricator

git-files-commits-table.py

Authored By
avivey
Jul 7 2016, 6:08 PM
Size
1 KB
Referenced Files
None
Subscribers
None

git-files-commits-table.py

#! /usr/bin/env python
# Produces a table of filenames x commits, showing where a file was touched.
# Useful for rebasing feature branch into reasonable commits.
# usage:
# git log --name-status --oneline origin/master.. | $0
import fileinput
files = set()
commits = list()
class Commit(object):
def __init__(self, title):
self.title = title
self.files = dict()
def addFile(self, filename, status):
self.files[filename] = status
curr_commit = None
for line in fileinput.input():
try:
if line[0] in '0123456789abcdef':
curr_commit = Commit(line)
commits.insert(0, curr_commit)
else:
v, f = line.split('\t', 2)
f = f.strip()
curr_commit.addFile(f, v)
files.add(f)
except:
print line
raise
name_len = 0
for f in files:
name_len = max(name_len, len(f))
name_pattern = '%' + str(name_len) + 's'
for f in files:
print name_pattern % f,
for c in commits:
s = c.files.get(f, ' ')
print s,
print

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
198763
Default Alt Text
git-files-commits-table.py (1 KB)

Event Timeline