Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4950861
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
May 10 2017, 9:08 PM
2017-05-10 21:08:15 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
git-files-commits-table.py
View Options
#! /usr/bin/env python2
# 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
)
elif
line
[
0
]
==
'R'
:
v
,
f1
,
f2
=
line
.
split
(
'
\t
'
)
f1
=
f1
.
strip
()
f2
=
f2
.
strip
()
curr_commit
.
addFile
(
f1
,
u'
\u2563
'
)
curr_commit
.
addFile
(
f2
,
u'
\u2560
'
)
files
.
add
(
f1
)
files
.
add
(
f2
)
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
648153
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