def test_gitrepo_local_nohead(tmpdir):
    """ Test operations on an empty git repository (commit/tag noop) """
    gitrepo = GitRepo(GitHubRepo('local-repo', '', ''), str(tmpdir))
    gitrepo.fetch_and_reset()
    gitrepo.describe()
    gitrepo.commit('Try to commit without changes')
    gitrepo.tag('tag')
    assert not gitrepo.diff()
    assert not gitrepo.describe()
    assert not gitrepo.get_hexsha()
def test_gitrepo_remote(tmpdir, gitrepo_remote):
    """ Test operations on a git repository with a remote """
    url = 'file://{}'.format(gitrepo_remote.path)
    gitrepo = GitRepo(GitHubRepo('local-repo', url, url), str(tmpdir))
    gitrepo.fetch_and_reset()
    assert not gitrepo.diff()
    assert gitrepo.describe()
    assert gitrepo.get_hexsha()
    testfile = os.path.join(str(tmpdir), 'local-repo', 'testfile')
    create_file(testfile)
    gitrepo.commit('Commit testfile')
    assert gitrepo.diff()
def test_gitrepo_local(tmpdir):
    """ Test operations on a local git repository """
    gitrepo = GitRepo(GitHubRepo('local-repo', '', ''), str(tmpdir))
    testfile = os.path.join(gitrepo.path, 'testfile')
    gitrepo.fetch_and_reset()
    create_file(testfile)
    gitrepo.commit('Commit testfile')
    gitrepo.tag('tag')
    assert gitrepo.diff()
    assert gitrepo.describe()
    assert gitrepo.get_hexsha()
    gitrepo.fetch_and_reset()
    assert os.path.isfile(testfile)