def Shared_commits_are_expanded__test():
    assert_equal([
        CodeLine("h1", "dt1", "a1", 0.5),
        CodeLine("h1", "dt1", "a2", 0.5),
    ], list(expand_authors([
        LogLine("h1", "dt1", "a1,a2"),
    ])))
def Normal_commits_are_not_expanded__test():
    assert_equal([
        CodeLine("h1", "dt1", "a1", 1.0),
        CodeLine("h2", "dt2", "a2", 1.0),
    ],
                 list(
                     expand_authors([
                         LogLine("h1", "dt1", "a1"),
                         LogLine("h2", "dt2", "a2"),
                     ])))
def Shared_commits_are_expanded__test():
    assert_equal(
        [
            CodeLine( "h1", "dt1", "a1", 0.5 ),
            CodeLine( "h1", "dt1", "a2", 0.5 ),
        ],
        list( expand_authors(
            [
                LogLine( "h1", "dt1", "a1,a2" ),
            ]
        ) )
    )
def Normal_commits_are_not_expanded__test():
    assert_equal(
        [
            CodeLine( "h1", "dt1", "a1", 1.0 ),
            CodeLine( "h2", "dt2", "a2", 1.0 ),
        ],
        list( expand_authors(
            [
                LogLine( "h1", "dt1", "a1" ),
                LogLine( "h2", "dt2", "a2" ),
            ]
        ) )
    )
def Multiple_commits__test():
    assert_equal([
        CodeLine("h1", "dt1", "a1", 1.0),
        CodeLine("h2", "dt2", "a1", 1.0 / 3),
        CodeLine("h2", "dt2", "a2", 1.0 / 3),
        CodeLine("h2", "dt2", "a3", 1.0 / 3),
        CodeLine("h4", "dt4", "a4", 1.0),
    ],
                 list(
                     expand_authors([
                         LogLine("h1", "dt1", "a1"),
                         LogLine("h2", "dt2", "a1,a2,a3"),
                         LogLine("h4", "dt4", "a4"),
                     ])))
def Multiple_commits__test():
    assert_equal(
        [
            CodeLine( "h1", "dt1", "a1", 1.0 ),
            CodeLine( "h2", "dt2", "a1", 1.0/3 ),
            CodeLine( "h2", "dt2", "a2", 1.0/3 ),
            CodeLine( "h2", "dt2", "a3", 1.0/3 ),
            CodeLine( "h4", "dt4", "a4", 1.0 ),
        ],
        list( expand_authors(
            [
                LogLine( "h1", "dt1", "a1" ),
                LogLine( "h2", "dt2", "a1,a2,a3" ),
                LogLine( "h4", "dt4", "a4" ),
            ]
        ) )
    )
Beispiel #7
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()