def summary(b, c): P = os.getcwd() repo = Repository(path=P) if c: click.echo(repo.summary(commit=c)) elif b: click.echo(repo.summary(branch_name=b)) else: click.echo(repo.summary())
def test_cannot_operate_without_repo_init(managed_tmpdir): repo = Repository(path=managed_tmpdir, exists=False) with pytest.raises(RuntimeError): repo.writer_lock_held() with pytest.raises(RuntimeError): repo.checkout() with pytest.raises(RuntimeError): repo.writer_lock_held() with pytest.raises(RuntimeError): repo.log() with pytest.raises(RuntimeError): repo.summary() with pytest.raises(RuntimeError): repo.merge('fail', 'master', 'nonexistant') with pytest.raises(RuntimeError): repo.create_branch('test') with pytest.raises(RuntimeError): repo.list_branches() with pytest.raises(RuntimeError): repo.force_release_writer_lock() with pytest.raises(RuntimeError): repo.remote.add('origin', 'foo') with pytest.raises(RuntimeError): repo.remote.remove('origin') with pytest.raises(RuntimeError): repo.remote.fetch('origin', 'master') with pytest.raises(RuntimeError): repo.remote.fetch_data('origin', branch='master') with pytest.raises(RuntimeError): repo.remote.list_all() with pytest.raises(RuntimeError): repo.remote.ping('origin') with pytest.raises(RuntimeError): repo.remote.push('origin', 'master') with pytest.raises(RuntimeError): repo.remove_branch('master') with pytest.raises(RuntimeError): repo.path with pytest.raises(RuntimeError): repo.version with pytest.raises(RuntimeError): repo.writer_lock_held with pytest.raises(RuntimeError): repo.size_human with pytest.raises(RuntimeError): repo.size_nbytes assert repo._env.repo_is_initialized is False
def summary(repo: Repository, startpoint): """Display content summary at STARTPOINT (short-digest or branch). If no argument is passed in, the staging area branch HEAD wil be used as the starting point. In order to recieve a machine readable, and more complete version of this information, please see the ``Repository.summary()`` method of the API. """ from hangar.records.commiting import expand_short_commit_digest if startpoint is None: click.echo(repo.summary()) elif startpoint in repo.list_branches(): click.echo(repo.summary(branch=startpoint)) else: base_commit = expand_short_commit_digest(repo._env.refenv, startpoint) click.echo(repo.summary(commit=base_commit))
def test_repo_summary_does_not_error_before_any_commit_made( capfd, managed_tmpdir): repo = Repository(path=managed_tmpdir, exists=False) repo.init(user_name='tester', user_email='*****@*****.**', remove_old=True) assert repo.summary() is None out, _ = capfd.readouterr() assert 'No commits have been made in the repository' in out repo._env._close_environments()
def test_summary(written_two_cmt_server_repo, capsys): server, base_repo = written_two_cmt_server_repo runner = CliRunner() with runner.isolated_filesystem(): with capsys.disabled(): P = getcwd() new_repo = Repository(P, exists=False) res = runner.invoke( cli.clone, ['--name', 'Foo Tester', '--email', '*****@*****.**', f'{server}'], obj=new_repo) assert res.exit_code == 0 assert new_repo.summary() == base_repo.summary() new_repo.summary() with capsys.disabled(): res = runner.invoke(cli.summary, obj=new_repo) assert res.stdout == f"{capsys.readouterr().out}\n"
def test_clone(written_two_cmt_server_repo): server, base_repo = written_two_cmt_server_repo runner = CliRunner() with runner.isolated_filesystem(): P = getcwd() new_repo = Repository(P, exists=False) res = runner.invoke( cli.clone, ['--name', 'Foo Tester', '--email', '*****@*****.**', f'{server}'], obj=new_repo) assert res.exit_code == 0 newLog = new_repo.log(return_contents=True) baseLog = base_repo.log(return_contents=True) assert newLog == baseLog assert new_repo.summary() == base_repo.summary()