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


Python git.Git类代码示例

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


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

示例1: test_get_timing_file_directory_removes_colon_from_directory_if_exists

    def test_get_timing_file_directory_removes_colon_from_directory_if_exists(self):
        Configuration['timings_directory'] = '/tmp/timings'
        git = Git("some_remote_value", 'origin', 'ref/to/some/branch')

        repo_directory = git.get_timing_file_directory('ssh://source_control.cr.com:1234/master')

        self.assertEqual(repo_directory, '/tmp/timings/source_control.cr.com1234/master')
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:7,代码来源:test_git.py

示例2: test_timing_file_path_happy_path

 def test_timing_file_path_happy_path(self):
     git_env = Git("ssh://scm.dev.box.net/box/www/current", 'origin', 'refs/changes/78/151978/27')
     timing_file = git_env.timing_file_path('QUnit')
     self.assertEquals(
         Configuration['base_directory'] +
         '/timings/master/scm.dev.box.net/box/www/current/QUnit.timing.json',
         timing_file
     )
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:8,代码来源:test_git.py

示例3: test_execute_git_remote_command_doesnt_auto_add_known_host_if_no_prompt

    def test_execute_git_remote_command_doesnt_auto_add_known_host_if_no_prompt(self):
        def expect_side_effect(*args, **kwargs):
            if args[0] == ['^User.*: ', '^Pass.*: ', '.*Are you sure you want to continue connecting.*']:
                raise pexpect.TIMEOUT('some_msg')
            return None

        self.mock_pexpect_child.expect.side_effect = expect_side_effect
        git = Git("some_remote_value", 'origin', 'ref/to/some/branch')
        git._execute_git_remote_command('some_command')
        self.assertEquals(self.mock_pexpect_child.sendline.call_count, 0)
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:10,代码来源:test_git.py

示例4: test_get_timing_file_directory_removes_colon_from_directory_if_exists

    def test_get_timing_file_directory_removes_colon_from_directory_if_exists(self):
        Configuration['timings_directory'] = join(expanduser('~'), 'tmp', 'timings')
        git = Git("some_remote_value", 'origin', 'ref/to/some/branch')

        actual_timing_directory = git.get_timing_file_directory('ssh://source_control.cr.com:1234/master')
        expected_timing_directory = join(
            Configuration['timings_directory'],
            'source_control.cr.com1234',
            'master',
        )

        self.assertEqual(expected_timing_directory, actual_timing_directory)
开发者ID:Medium,项目名称:ClusterRunner,代码行数:12,代码来源:test_git.py

示例5: test_execute_command_in_project_type_specifies_cwd_if_doesnt_exist

    def test_execute_command_in_project_type_specifies_cwd_if_doesnt_exist(self):
        project_type_popen_patch = self._patch_popen()

        git_env = Git("ssh://scm.dev.box.net/box/www/current", 'origin', 'refs/changes/78/151978/27')
        git_env.project_directory = 'proj_dir'
        git_env.execute_command_in_project('some_command')
        project_type_popen_patch.assert_called_once_with(
            'export PROJECT_DIR="proj_dir"; some_command',
            cwd=None,
            shell=ANY,
            stdout=ANY,
            stderr=ANY,
            start_new_session=ANY,
        )
开发者ID:linearregression,项目名称:ClusterRunner,代码行数:14,代码来源:test_git.py

示例6: test_slave_param_overrides_when_get_project_from_master_is_disabled

    def test_slave_param_overrides_when_get_project_from_master_is_disabled(self):
        Configuration['get_project_from_master'] = False

        git = Git(url='http://original-user-specified-url.test/repo-path/repo-name')
        actual_overrides = git.slave_param_overrides()

        self.assertFalse(
            'url' in actual_overrides,
            '"url" should not be in the params to override when "get_project_from_master" is False',
        )
        self.assertFalse(
            'branch' in actual_overrides,
            '"branch" should not be in the params to override when "get_project_from_master" is False',
        )
开发者ID:Medium,项目名称:ClusterRunner,代码行数:14,代码来源:test_git.py

示例7: test_timing_file_path_happy_path

 def test_timing_file_path_happy_path(self):
     git_env = Git("ssh://scm.dev.box.net/box/www/current", 'origin', 'refs/changes/78/151978/27')
     actual_timing_file_sys_path = git_env.timing_file_path('QUnit')
     expected_timing_file_sys_path = join(
         Configuration['base_directory'],
         'timings',
         'master',
         'scm.dev.box.net',
         'box',
         'www',
         'current',
         'QUnit.timing.json',
     )
     self.assertEquals(expected_timing_file_sys_path, actual_timing_file_sys_path)
开发者ID:Medium,项目名称:ClusterRunner,代码行数:14,代码来源:test_git.py

示例8: test_get_timing_file_directory

    def test_get_timing_file_directory(self):
        Configuration['timings_directory'] = '/home/cr_user/.clusterrunner/timing'
        url = 'http://scm.example.com/path/to/project'

        timings_path = Git.get_timing_file_directory(url)

        self.assertEqual(timings_path, '/home/cr_user/.clusterrunner/timing/scm.example.com/path/to/project')
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:7,代码来源:test_git.py

示例9: test_get_full_repo_directory

    def test_get_full_repo_directory(self):
        Configuration['repo_directory'] = '/home/cr_user/.clusterrunner/repos/master'
        url = 'http://scm.example.com/path/to/project'

        repo_path = Git.get_full_repo_directory(url)

        self.assertEqual(repo_path, '/home/cr_user/.clusterrunner/repos/master/scm.example.com/path/to/project')
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:7,代码来源:test_git.py

示例10: test_slave_param_overrides_returns_expected

    def test_slave_param_overrides_returns_expected(self):
        self._patch_popen({
            'git rev-parse FETCH_HEAD': _FakePopenResult(stdout='deadbee123\n')
        })
        Configuration['repo_directory'] = '/repo-directory'

        git = Git(url='http://original-user-specified-url.test/repo-path/repo-name')
        git.fetch_project()
        actual_overrides = git.slave_param_overrides()

        expected_overrides = {
            'url': 'ssh://fake_hostname/repodirectory/originaluserspecifiedurl.test/repopath/reponame',
            'branch': 'refs/clusterrunner/deadbee123',
        }
        self.assertEqual(expected_overrides, actual_overrides, 'Slave param overrides from Git object should match'
                                                               'expected.')
开发者ID:linearregression,项目名称:ClusterRunner,代码行数:16,代码来源:test_git.py

示例11: test_execute_git_command_auto_sets_strict_host_option_correctly

    def test_execute_git_command_auto_sets_strict_host_option_correctly(self, strict_host_check_setting):
        Configuration['git_strict_host_key_checking'] = strict_host_check_setting
        popen_mock = self._patch_popen()

        git = Git(url='http://some-user-url.com/repo-path/repo-name')
        git._execute_git_command_in_repo_and_raise_on_failure('fakecmd')

        if strict_host_check_setting:
            expected_ssh_arg = '-o StrictHostKeyChecking=yes'
        else:
            expected_ssh_arg = '-o StrictHostKeyChecking=no'

        expected_call = call(AnyStringMatching(expected_ssh_arg),
                             start_new_session=ANY, stdout=ANY, stderr=ANY, cwd=ANY, shell=ANY)
        self.assertIn(expected_call, popen_mock.call_args_list, 'Executed git command should include the correct '
                                                                'option for StrictHostKeyChecking.')
开发者ID:Medium,项目名称:ClusterRunner,代码行数:16,代码来源:test_git.py

示例12: test_execute_command_in_project_type_specifies_cwd_if_doesnt_exist

    def test_execute_command_in_project_type_specifies_cwd_if_doesnt_exist(self):
        os_path_exists_patch = self.patch('os.path.exists')
        os_path_exists_patch.return_value = False
        project_type_popen_patch = self.patch('app.project_type.project_type.Popen')
        project_type_popen_patch.return_value.communicate.return_value = None, None
        project_type_popen_patch.return_value.returncode = 0

        git_env = Git("ssh://scm.dev.box.net/box/www/current", 'origin', 'refs/changes/78/151978/27')
        git_env.project_directory = 'proj_dir'
        git_env.execute_command_in_project('some_command')
        project_type_popen_patch.assert_called_once_with(
            'export PROJECT_DIR="proj_dir"; some_command',
            stderr=-2,
            cwd=None,
            shell=True,
            stdout=-1
        )
开发者ID:drobertduke,项目名称:ClusterRunner,代码行数:17,代码来源:test_git.py

示例13: test_execute_command_in_project_type_specifies_cwd_if_doesnt_exist

    def test_execute_command_in_project_type_specifies_cwd_if_doesnt_exist(self):
        project_type_popen_patch = self._patch_popen()

        fake_project_directory = 'proj_dir'
        fake_command = 'some_command'
        git_env = Git("ssh://scm.dev.box.net/box/www/current", 'origin', 'refs/changes/78/151978/27')
        git_env.project_directory = fake_project_directory
        git_env.execute_command_in_project(fake_command)
        env_setter = get_environment_variable_setter_command('PROJECT_DIR', fake_project_directory)
        project_type_popen_patch.assert_called_once_with(
            '{} {}'.format(env_setter, fake_command),
            cwd=None,
            shell=ANY,
            stdout=ANY,
            stderr=ANY,
            start_new_session=ANY,
        )
开发者ID:Medium,项目名称:ClusterRunner,代码行数:17,代码来源:test_git.py

示例14: test_fetch_project_passes_depth_parameter_for_shallow_clone_configuration

    def test_fetch_project_passes_depth_parameter_for_shallow_clone_configuration(self, shallow_clone):
        Configuration['shallow_clones'] = shallow_clone
        self.os_path_isfile_mock.return_value = False
        self.os_path_exists_mock.return_value = False
        mock_popen = self._patch_popen({'git rev-parse$': _FakePopenResult(return_code=1)})

        git = Git(url='http://original-user-specified-url.test/repo-path/repo-name')
        git.fetch_project()

        git_clone_call = call(AnyStringMatching('git clone --depth=1'), start_new_session=ANY,
                              stdout=ANY, stderr=ANY, cwd=ANY, shell=ANY)
        if shallow_clone:
            self.assertIn(git_clone_call, mock_popen.call_args_list, 'If shallow cloning, the --depth=1 parameter '
                                                                     'should be present.')
        else:
            self.assertNotIn(git_clone_call, mock_popen.call_args_list, 'If deep cloning, the --depth=1 parameter '
                                                                        'must be absent.')
开发者ID:Medium,项目名称:ClusterRunner,代码行数:17,代码来源:test_git.py

示例15: test_repo_is_cloned_if_and_only_if_rev_parse_fails

    def test_repo_is_cloned_if_and_only_if_rev_parse_fails(self, rev_parse_return_code, expect_git_clone_call):
        mock_popen = self._patch_popen({
            'git rev-parse$': _FakePopenResult(return_code=rev_parse_return_code)
        })
        Configuration['repo_directory'] = '/repo-directory'

        git = Git(url='http://original-user-specified-url.test/repo-path/repo-name')
        git.fetch_project()

        git_clone_call = call(AnyStringMatching('git clone'), start_new_session=ANY,
                              stdout=ANY, stderr=ANY, cwd=ANY, shell=ANY)
        if expect_git_clone_call:
            self.assertIn(git_clone_call, mock_popen.call_args_list, 'If "git rev-parse" returns a failing exit code, '
                                                                     '"git clone" should be called.')
        else:
            self.assertNotIn(git_clone_call, mock_popen.call_args_list, 'If "git rev-parse" returns a successful exit '
                                                                        'code, "git clone" should not be called.')
开发者ID:Medium,项目名称:ClusterRunner,代码行数:17,代码来源:test_git.py


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