Esempio n. 1
0
def main( argv, out, err ):
    try:
        git = Git( RawGit() )
        csv = Csv(
            out,
            ( "Commit", "Date", "Author", "Added", "Removed", "File" )
        )
        for cod in expand_lines( git, expand_authors( git.log() ) ):
            csv.line( (
                cod.commit_hash,
                cod.date.date().isoformat(),
                cod.author,
                cod.added,
                cod.removed,
                cod.filename,
            ) )
    except subprocess.CalledProcessError as e:
        print(str( e ))
        sys.exit( 1 )
    finally:
        out.flush()
def Expand_lines_makes_one_line_for_each_modified_file():
    git = Git( FakeGit( """2976 Andy Balaam "desc."
10      2       f.txt
1       0       g.txt
""", """2976 Peter Broadbent "desc2."
0       18      h.txt
4       14      i.txt

""") )
    assert_equal(
        [
            DataLine( "h", "d", "a", 10, 2, "f.txt" ),
            DataLine( "h", "d", "a",  1, 0, "g.txt" ),
            DataLine( "j", "e", "b",  0, 9, "h.txt" ),
            DataLine( "j", "e", "b",  2, 7, "i.txt" ),
        ],
        expand_lines(
            git,
            CodeLine( "h", "d", "a", 1.0 ),
            CodeLine( "j", "j", "b", 0.5 ),
        )
    )
def Expand_lines_makes_one_line_for_each_modified_file():
    git = Git(
        FakeGit(
            """2976 Andy Balaam "desc."
10      2       f.txt
1       0       g.txt
""", """2976 Peter Broadbent "desc2."
0       18      h.txt
4       14      i.txt

"""))
    assert_equal([
        DataLine("h", "d", "a", 10, 2, "f.txt"),
        DataLine("h", "d", "a", 1, 0, "g.txt"),
        DataLine("j", "e", "b", 0, 9, "h.txt"),
        DataLine("j", "e", "b", 2, 7, "i.txt"),
    ],
                 expand_lines(
                     git,
                     CodeLine("h", "d", "a", 1.0),
                     CodeLine("j", "j", "b", 0.5),
                 ))