How to use gita - 10 common examples

To help you get started, we’ve selected a few gita examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nosarthur / gita / tests / test_main.py View on Github external
def test_ungroup(mock_write, _, __, input, expected):
    utils.get_groups.cache_clear()
    args = ['ungroup'] + shlex.split(input)
    __main__.main(args)
    mock_write.assert_called_once_with(expected, 'w')
github nosarthur / gita / tests / test_main.py View on Github external
def test_superman(mock_run, _, input):
    mock_run.reset_mock()
    args = ['super', 'repo7'] + shlex.split(input)
    __main__.main(args)
    expected_cmds = ['git'] + shlex.split(input)
    mock_run.assert_called_once_with(expected_cmds, cwd='path7')
github nosarthur / gita / tests / test_main.py View on Github external
def test_ungroup(mock_write, _, __, input, expected):
    utils.get_groups.cache_clear()
    args = ['ungroup'] + shlex.split(input)
    __main__.main(args)
    mock_write.assert_called_once_with(expected, 'w')
github nosarthur / gita / tests / test_main.py View on Github external
def test_rename(mock_rename, _, __):
    utils.get_repos.cache_clear()
    args = ['rename', 'repo1', 'abc']
    __main__.main(args)
    mock_rename.assert_called_once_with(
        {'repo1': '/a/bcd/repo1', 'repo2': '/e/fgh/repo2',
            'xxx': '/a/b/c/repo3'},
        'repo1', 'abc')
github nosarthur / gita / tests / test_main.py View on Github external
utils.get_repos.cache_clear()

        __main__.main(['ls'])
        out, err = capfd.readouterr()
        assert err == ''
        assert 'gita\n' == out

        __main__.main(['ll'])
        out, err = capfd.readouterr()
        assert err == ''
        assert 'gita' in out

        __main__.main(['ls', 'gita'])
        out, err = capfd.readouterr()
        assert err == ''
        assert out.strip() == utils.get_repos()['gita']
github nosarthur / gita / tests / test_main.py View on Github external
def testLl(self, mock_path_fname, capfd, tmp_path):
        """ functional test """
        # avoid modifying the local configuration
        mock_path_fname.return_value = tmp_path / 'path_config.txt'
        __main__.main(['add', '.'])
        out, err = capfd.readouterr()
        assert err == ''
        assert 'Found 1 new repo(s).\n' == out

        # in production this is not needed
        utils.get_repos.cache_clear()

        __main__.main(['ls'])
        out, err = capfd.readouterr()
        assert err == ''
        assert 'gita\n' == out

        __main__.main(['ll'])
        out, err = capfd.readouterr()
        assert err == ''
        assert 'gita' in out

        __main__.main(['ls', 'gita'])
        out, err = capfd.readouterr()
        assert err == ''
        assert out.strip() == utils.get_repos()['gita']
github nosarthur / gita / tests / test_utils.py View on Github external
def test_get_repos(mock_path_fname, _, path_fname, expected):
    mock_path_fname.return_value = path_fname
    utils.get_repos.cache_clear()
    repos = utils.get_repos()
    assert repos == expected
github nosarthur / gita / tests / test_utils.py View on Github external
def test_custom_push_cmd(*_):
    with patch('builtins.open',
               mock_open(read_data='push:\n  cmd: hand\n  help: me')):
        cmds = utils.get_cmds_from_files()
    assert cmds['push'] == {'cmd': 'hand', 'help': 'me'}
github nosarthur / gita / tests / test_main.py View on Github external
def test_async_fetch(*_):
    __main__.main(['fetch'])
    mock_run = utils.run_async.mock
    assert mock_run.call_count == 2
    cmds = ['git', 'fetch']
    # print(mock_run.call_args_list)
    mock_run.assert_any_call('repo1', '/a/bc', cmds)
    mock_run.assert_any_call('repo2', '/d/efg', cmds)
github nosarthur / gita / tests / test_utils.py View on Github external
def test_describe(test_input, diff_return, expected, monkeypatch):
    monkeypatch.setattr(info, 'get_head', lambda x: 'repo')
    monkeypatch.setattr(info, 'run_quiet_diff', lambda _: diff_return)
    monkeypatch.setattr(info, 'get_commit_msg', lambda _: "msg")
    monkeypatch.setattr(info, 'has_untracked', lambda: True)
    monkeypatch.setattr('os.chdir', lambda x: None)
    print('expected: ', repr(expected))
    print('got:      ', repr(next(utils.describe(test_input))))
    assert expected == next(utils.describe(test_input))