def show_log(args, repo, extension):
    """
    Show latest git logs with specified number of entries and maybe for a
    specific file.
    """
    args = args.split()
    format = "format:%C(blue)%h %Cgreen%C(bold)%ad %Creset%s"
    dateformat = "short"

    if len(args) >= 1:
        if os.path.isfile(os.path.join(os.getcwd(), add_fileextension(args[0], extension))):
            file = add_fileextension(args[0], extension)

            # Command: log Article 12
            try:
                count = args[1]
                print("Last %s commits for %s" % (count, file))
                print(repo.git.log(file, pretty=format, n=count,
                                   date=dateformat, follow=True))
            # Command: log Article
            except IndexError:
                count = 10
                print("Last %s commits for %s" % (count, file))
                print(repo.git.log(file, pretty=format, n=count,
                                   date=dateformat, follow=True))
            except git.exc.GitCommandError:
                print("Error: git command resulted in an error")
        else:
            count = args[0]
            # Command: log 12 Article
            try:
                file = add_fileextension(args[1], extension)
                print("Last %s commits for %s" % (count, file))
                print(repo.git.log(file, pretty=format, n=count,
                                   date=dateformat, follow=True))
            # Command: log 12
            except IndexError:
                print("Last %s commits" % count)
                print(repo.git.log(pretty=format, n=count,
                                   date=dateformat))
            except git.exc.GitCommandError:
                print("Error: git command resulted in an error")

    # Command: log
    elif len(args) == 0:
        count = 10
        print("Last %s commits" % count)
        try:
            print(repo.git.log(pretty=format, n=count, date=dateformat))
        except git.exc.GitCommandError:
            print("Error: git may not be configured on your system.")
dataset/ETHPy150Open noqqe/cmddocs/cmddocs/articles.py/show_log/original