当前位置: 首页>>代码示例>>Python>>正文


Python history.Repository类代码示例

本文整理汇总了Python中passpie.history.Repository的典型用法代码示例。如果您正苦于以下问题:Python Repository类的具体用法?Python Repository怎么用?Python Repository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_git_init_creates_a_repository_on_path

def test_git_init_creates_a_repository_on_path(mocker, mock_process):
    path = 'some_path'
    cmd = ['git', 'init', path]
    repo = Repository(path)
    repo.init()

    mock_process.call.assert_called_once_with(cmd)
开发者ID:gitter-badger,项目名称:passpie,代码行数:7,代码来源:test_history.py

示例2: test_git_commit_calls_push_when_autopush_set

def test_git_commit_calls_push_when_autopush_set(mocker, mock_process):
    message = 'Initial commit'
    cmd = ['git', 'commit', '-m', message]
    repo = Repository('path', autopush=['origin', 'master'])
    mocker.patch.object(repo, 'push')

    repo.commit(message)
    assert repo.push.called
开发者ID:gitter-badger,项目名称:passpie,代码行数:8,代码来源:test_history.py

示例3: test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found

def test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found(mocker, mock_process):
    sha_list = []
    index = 0

    repo = Repository('path')
    mocker.patch.object(repo, 'sha_list', return_value=sha_list)
    repo.reset(index)

    mock_process.call.called is False
开发者ID:gitter-badger,项目名称:passpie,代码行数:9,代码来源:test_history.py

示例4: test_git_sha_list_has_call_with_expected_command

def test_git_sha_list_has_call_with_expected_command(mocker, mock_process):
    output = 'a\nb'
    mock_process.call.return_value = (output, '')
    cmd = ['git', 'log', '--reverse', '--pretty=format:%h']
    repo = Repository('path')
    result = repo.sha_list()

    assert result == output.splitlines()
    mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
开发者ID:gitter-badger,项目名称:passpie,代码行数:9,代码来源:test_history.py

示例5: test_git_commit_creates_commit_with_message

def test_git_commit_creates_commit_with_message(mocker, mock_process):
    message = 'Initial commit'
    cmd = ['git', 'commit', '-m', message]
    repo = Repository('path')
    mocker.patch.object(repo, 'add')

    repo.commit(message)

    repo.add.assert_called_once_with(all=True)
    mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
开发者ID:gitter-badger,项目名称:passpie,代码行数:10,代码来源:test_history.py

示例6: test_git_commit_creates_commit_with_message

def test_git_commit_creates_commit_with_message(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    path = 'some_path'
    message = 'Initial commit'

    git = Repository(path)
    git.commit(message)

    MockRepo().git.add.assert_called_once_with(all=True)
    MockRepo().index.commit.assert_called_once_with(message)
开发者ID:Atlantic777,项目名称:passpie,代码行数:10,代码来源:test_history.py

示例7: test_commit_by_index_returns_none_when_index_not_found

def test_commit_by_index_returns_none_when_index_not_found(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = []
    mock_repo.iter_commits.return_value = commits
    index = len(commits) + 1

    git = Repository('path')
    commit = git.commit_by_index(index)

    assert commit is None
开发者ID:Atlantic777,项目名称:passpie,代码行数:11,代码来源:test_history.py

示例8: test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found

def test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = []
    mock_repo.iter_commits.return_value = commits
    index = len(commits) + 1

    git = Repository('path')
    commit = git.reset(index)

    assert mock_repo.git.reset.called is False
开发者ID:Atlantic777,项目名称:passpie,代码行数:11,代码来源:test_history.py

示例9: test_commit_by_index_returns_found_commit_when_index_exists

def test_commit_by_index_returns_found_commit_when_index_exists(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = ['initial commit']
    mock_repo.iter_commits.return_value = commits
    index = 0

    git = Repository('path')
    commit = git.commit_by_index(index)

    assert commit == commits[0]
开发者ID:Atlantic777,项目名称:passpie,代码行数:11,代码来源:test_history.py

示例10: test_reset_call_git_reset_hard_on_commit_when_found

def test_reset_call_git_reset_hard_on_commit_when_found(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = [MagicMock()]
    mock_repo.iter_commits.return_value = commits
    index = 0

    git = Repository('path')
    commit = git.reset(index)

    assert mock_repo.git.reset.called is True
    mock_repo.git.reset.assert_called_once_with('--hard', commits[0].hexsha)
开发者ID:Atlantic777,项目名称:passpie,代码行数:12,代码来源:test_history.py

示例11: test_git_commit_list_has_expected_commit_list

def test_git_commit_list_has_expected_commit_list(mocker, mock_process):
    commit_list = [
        'another commit',
        'initial commit'
    ]
    mock_process.call.return_value = ("\n".join(commit_list), 'no error')
    cmd = ['git', 'log', '--reverse', '--pretty=format:%s']
    repo = Repository('path')
    commits = repo.commit_list()

    assert len(repo.commit_list()) == len(commits)
    mock_process.call.assert_any_call(cmd, cwd=repo.path)
开发者ID:gitter-badger,项目名称:passpie,代码行数:12,代码来源:test_history.py

示例12: test_reset_call_git_reset_hard_on_commit_when_found

def test_reset_call_git_reset_hard_on_commit_when_found(mocker, mock_process):
    sha_list = [
        'd6b52b5',
        '34c5439',
        '5910c2b',
    ]
    index = 0
    cmd = ['git', 'reset', '--hard', sha_list[index]]

    repo = Repository('path')
    mocker.patch.object(repo, 'sha_list', return_value=sha_list)
    repo.reset(index)

    mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
开发者ID:gitter-badger,项目名称:passpie,代码行数:14,代码来源:test_history.py

示例13: test_git_commit_list_has_expected_reversed_commits_with_index

def test_git_commit_list_has_expected_reversed_commits_with_index(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = [
        'another commit',
        'initial commit'
    ]
    mock_repo.iter_commits.return_value = commits
    path = 'some_path'

    git = Repository(path)
    commit_list = git.commit_list()

    assert len(commit_list) == len(commits)
    assert [i for i, _ in commit_list] == list(reversed(list(range(len(commits)))))
开发者ID:Atlantic777,项目名称:passpie,代码行数:15,代码来源:test_history.py

示例14: test_git_push_calls_expected_command_when_remote_branch_is_passed

def test_git_push_calls_expected_command_when_remote_branch_is_passed(mocker, mock_process):
    cmd = ['git', 'push', 'another_origin', 'another_branch']
    repo = Repository('path')
    repo.push(remote='another_origin', branch='another_branch')

    mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
开发者ID:gitter-badger,项目名称:passpie,代码行数:6,代码来源:test_history.py

示例15: test_git_push_calls_expected_command

def test_git_push_calls_expected_command(mocker, mock_process):
    cmd = ['git', 'push', 'origin', 'master']
    repo = Repository('path')
    repo.push()

    mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
开发者ID:gitter-badger,项目名称:passpie,代码行数:6,代码来源:test_history.py


注:本文中的passpie.history.Repository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。