Ejemplo n.º 1
0
def test_changelog(cd_to_tmpdir):
    git = TestGit()
    git.initialize()
    message_1 = "mess1"
    git.commit_file("foo.txt", "foo\n", message=message_1)
    message_2 = "mess2"
    git.commit_file("foo.txt", "bar\n", message=message_2)
    commits = git.get_log("HEAD~2", "HEAD")
    assert len(commits) == 2
    assert commits[0]["message"] == message_1
    assert commits[1]["message"] == message_2
Ejemplo n.º 2
0
def test_ending_newlines(cd_to_tmpdir):
    """ Test Ending New Lines """
    git = TestGit()
    git.initialize()
    message_1 = "mess1"
    file_1 = "foo.txt"
    content_1 = "\nfoo\nbar\n\n"
    git.commit_file(file_1, content_1, message=message_1)
    # Test git subcommand which doesn't keep the last newline by default
    rc, out = git.status(raises=False)
    assert rc == 0
    assert out[-1] != "\n"
    rc, out = git.status(raises=False, keep_last_newline=True)
    assert rc == 0
    assert out[-1] == "\n"
    # Test git subcommand which KEEP the last newline by default
    rc, out = git.show("master:foo.txt", raises=False)
    assert rc == 0
    assert out[-1] == "\n"
    assert out == content_1
    rc, out = git.show("master:foo.txt", raises=False, keep_last_newline=False)
    assert rc == 0
    assert out[-1] != "\n"
    assert out != content_1