Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1715128
git-files-commits-table.py
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
avivey
Jul 7 2016, 6:08 PM
2016-07-07 18:08:45 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
git-files-commits-table.py
View Options
#! /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
Details
Attached
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)
Attached To
Mode
P1998 git-files-commits-table.py
Attached
Detach File
Event Timeline
Log In to Comment