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


Python vcstools.GitClient类代码示例

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


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

示例1: test_get_default_remote_version_label

 def test_get_default_remote_version_label(self):
     url = self.remote_path
     client = GitClient(self.local_path)
     self.assertTrue(client.checkout(url))
     self.assertEqual(client.get_default_remote_version_label(), 'master')
     subprocess.check_call("git symbolic-ref HEAD refs/heads/test_branch", shell=True, cwd=self.remote_path)
     self.assertEqual(client.get_default_remote_version_label(), 'test_branch')
开发者ID:esteve,项目名称:vcstools,代码行数:7,代码来源:test_git.py

示例2: test_checkout_no_unnecessary_updates_other_branch

    def test_checkout_no_unnecessary_updates_other_branch(self):
        client = GitClient(self.local_path)
        client.fetches = 0
        client.submodules = 0
        client.fast_forwards = 0

        def ifetch(self):
            self.fetches += 1
            return True

        def iff(self, branch_parent, fetch=True, verbose=False):
            self.fast_forwards += 1
            return True

        def isubm(self, verbose=False, timeout=None):
            self.submodules += 1
            return True
        client._do_fetch = types.MethodType(ifetch, client)
        client._do_fast_forward = types.MethodType(iff, client)
        client._update_submodules = types.MethodType(isubm, client)
        url = self.remote_path
        self.assertFalse(client.path_exists())
        self.assertFalse(client.detect_presence())
        self.assertTrue(client.checkout(url, 'test_branch'))
        self.assertEqual(1, client.submodules)
        self.assertEqual(0, client.fetches)
        self.assertEqual(0, client.fast_forwards)
开发者ID:esteve,项目名称:vcstools,代码行数:27,代码来源:test_git.py

示例3: test_get_environment_metadata

 def test_get_environment_metadata(self):
     # Verify that metadata is generated
     directory = tempfile.mkdtemp()
     self.directories['local'] = directory
     local_path = os.path.join(directory, "local")
     client = GitClient(local_path)
     self.assertTrue('version' in client.get_environment_metadata())
开发者ID:esteve,项目名称:vcstools,代码行数:7,代码来源:test_git.py

示例4: test_get_log_defaults

 def test_get_log_defaults(self):
     client = GitClient(self.local_path)
     log = client.get_log()
     self.assertEquals(self.n_commits + 1, len(log))
     self.assertEquals('local_%d' % (self.n_commits - 1), log[0]['message'])
     for key in ['id', 'author', 'email', 'date', 'message']:
         self.assertTrue(log[0][key] is not None, key)
开发者ID:esteve,项目名称:vcstools,代码行数:7,代码来源:test_git.py

示例5: setUpClass

    def setUpClass(self):
        GitClientTestSetups.setUpClass()

        client = GitClient(self.local_path)
        client.checkout(self.remote_path, self.readonly_version)

        self.basepath_export = os.path.join(self.root_directory, 'export')
开发者ID:esteve,项目名称:vcstools,代码行数:7,代码来源:test_git.py

示例6: testDiffRelpath

    def testDiffRelpath(self):
        client = GitClient(self.local_path)
        self.assertTrue(client.path_exists())
        self.assertTrue(client.detect_presence())
        self.assertEquals(
            '''\
diff --git ros/added.txt ros/added.txt
new file mode 100644
index 0000000..454f6b3
--- /dev/null
+++ ros/added.txt
@@ -0,0 +1 @@
+0123456789abcdef
\\ No newline at end of file
diff --git ros/deleted-fs.txt ros/deleted-fs.txt
deleted file mode 100644
index e69de29..0000000
diff --git ros/deleted.txt ros/deleted.txt
deleted file mode 100644
index e69de29..0000000
diff --git ros/modified-fs.txt ros/modified-fs.txt
index e69de29..454f6b3 100644
--- ros/modified-fs.txt
+++ ros/modified-fs.txt
@@ -0,0 +1 @@
+0123456789abcdef
\\ No newline at end of file
diff --git ros/modified.txt ros/modified.txt
index e69de29..454f6b3 100644
--- ros/modified.txt
+++ ros/modified.txt
@@ -0,0 +1 @@
+0123456789abcdef
\\ No newline at end of file''',
            client.get_diff(basepath=os.path.dirname(self.local_path)).rstrip())
开发者ID:vcstools,项目名称:vcstools,代码行数:35,代码来源:test_git.py

示例7: setUp

    def setUp(self):
        client = GitClient(self.local_path)
        client.checkout(self.remote_path)
        # Create some local untracking branch
        subprocess.check_call("git checkout test_tag -b localbranch", shell=True, cwd=self.local_path)
        subprocess.check_call("touch local.txt", shell=True, cwd=self.local_path)
        subprocess.check_call("git add *", shell=True, cwd=self.local_path)
        subprocess.check_call("git commit -m my_branch", shell=True, cwd=self.local_path)
        subprocess.check_call("git tag my_branch_tag", shell=True, cwd=self.local_path)
        po = subprocess.Popen("git log -n 1 --pretty=format:\"%H\"", shell=True, cwd=self.local_path, stdout=subprocess.PIPE)
        self.untracked_version = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')

        # Go detached to create some dangling commits
        subprocess.check_call("git checkout test_tag", shell=True, cwd=self.local_path)
        # create a commit only referenced by tag
        subprocess.check_call("touch tagged.txt", shell=True, cwd=self.local_path)
        subprocess.check_call("git add *", shell=True, cwd=self.local_path)
        subprocess.check_call("git commit -m no_branch", shell=True, cwd=self.local_path)
        subprocess.check_call("git tag no_br_tag", shell=True, cwd=self.local_path)
        # create a dangling commit
        subprocess.check_call("touch dangling.txt", shell=True, cwd=self.local_path)
        subprocess.check_call("git add *", shell=True, cwd=self.local_path)
        subprocess.check_call("git commit -m dangling", shell=True, cwd=self.local_path)

        po = subprocess.Popen("git log -n 1 --pretty=format:\"%H\"", shell=True, cwd=self.local_path, stdout=subprocess.PIPE)
        self.dangling_version = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')

        # go back to master to make head point somewhere else
        subprocess.check_call("git checkout master", shell=True, cwd=self.local_path)
开发者ID:btubbs,项目名称:vcstools,代码行数:29,代码来源:test_git.py

示例8: test_checkout_dir_exists

 def test_checkout_dir_exists(self):
     url = self.remote_path
     client = GitClient(self.local_path)
     self.assertFalse(client.path_exists())
     os.makedirs(self.local_path)
     self.assertTrue(client.checkout(url))
     # non-empty
     self.assertFalse(client.checkout(url))
开发者ID:esteve,项目名称:vcstools,代码行数:8,代码来源:test_git.py

示例9: test_get_affected_files

    def test_get_affected_files(self):
        client = GitClient(self.local_path)
        affected = client.get_affected_files(client.get_log()[0]['id'])

        self.assertEqual(sorted(['local_file']),
                         sorted(affected))

        self.assertEquals(['local_file'], affected)
开发者ID:mocudev,项目名称:vcstools,代码行数:8,代码来源:test_git.py

示例10: test_fast_forward_simple_ref

    def test_fast_forward_simple_ref(self):
        url = self.remote_path
        client = GitClient(self.local_path)
        self.assertTrue(client.checkout(url, "master"))
        subprocess.check_call("git reset --hard test_tag", shell=True, cwd=self.local_path)
        # replace "refs/head/master" with just "master"
        subprocess.check_call("git config --replace-all branch.master.merge master", shell=True, cwd=self.local_path)

        self.assertTrue(client._get_branch_parent() is not (None, None))
开发者ID:esteve,项目名称:vcstools,代码行数:9,代码来源:test_git.py

示例11: setUp

    def setUp(self):
        client = GitClient(self.local_path)
        client.checkout(self.remote_path)
        # Create some local untracking branch

        subprocess.check_call("git checkout test_tag -b localbranch", shell=True, cwd=self.local_path)
        subprocess.check_call("touch local_file", shell=True, cwd=self.local_path)
        subprocess.check_call("git add local_file", shell=True, cwd=self.local_path)
        subprocess.check_call("git commit -m \"local_file\"", shell=True, cwd=self.local_path)
开发者ID:mocudev,项目名称:vcstools,代码行数:9,代码来源:test_git.py

示例12: testExportRepository

    def testExportRepository(self):
        client = GitClient(self.local_path)
        self.assertTrue(
          client.export_repository(self.readonly_version, self.basepath_export)
        )

        self.assertTrue(os.path.exists(self.basepath_export + '.tar.gz'))
        self.assertFalse(os.path.exists(self.basepath_export + '.tar'))
        self.assertFalse(os.path.exists(self.basepath_export))
开发者ID:jamuraa,项目名称:vcstools,代码行数:9,代码来源:test_git.py

示例13: test_fast_forward_diverged

 def test_fast_forward_diverged(self):
     url = self.remote_path
     client = GitClient(self.local_path)
     self.assertTrue(client.checkout(url, "master"))
     subprocess.check_call("git reset --hard test_tag", shell=True, cwd=self.local_path)
     subprocess.check_call("touch diverged.txt", shell=True, cwd=self.local_path)
     subprocess.check_call("git add *", shell=True, cwd=self.local_path)
     subprocess.check_call("git commit -m diverge", shell=True, cwd=self.local_path)
     # fail because we have diverged
     self.assertFalse(client.update('master'))
开发者ID:esteve,项目名称:vcstools,代码行数:10,代码来源:test_git.py

示例14: test_get_current_version_label

 def test_get_current_version_label(self):
     client = GitClient(path=self.local_path)
     # with detached local status
     client.checkout(url=self.remote_path, version='test_tag')
     self.assertEqual(client.get_current_version_label(), '<detached>')
     # when difference between local and tracking branch
     client.update(version='master')
     self.assertEqual(client.get_current_version_label(), 'master')
     # with other tracking branch
     cmd = 'git config --replace-all branch.master.merge test_branch'
     subprocess.check_call(cmd, shell=True, cwd=self.local_path)
     self.assertEqual(client.get_current_version_label(),
                      'master < test_branch')
     # with other remote
     for cmd in [
             'git remote add remote2 %s' % self.remote_path,
             'git config --replace-all branch.master.remote remote2',
             'git fetch remote2']:
         subprocess.check_call(cmd, shell=True, cwd=self.local_path)
     self.assertEqual(client.get_current_version_label(),
                      'master < remote2/test_branch')
     # return remote back to original config
     for cmd in [
          'git config --replace-all branch.master.remote origin',
          'git config --replace-all branch.master.merge refs/heads/master']:
         subprocess.check_call(cmd, shell=True, cwd=self.local_path)
开发者ID:esteve,项目名称:vcstools,代码行数:26,代码来源:test_git.py

示例15: setUp

 def setUp(self):
     client = GitClient(self.local_path)
     client.checkout(self.remote_path)
     subprocess.check_call("git checkout test_tag", shell=True, cwd=self.local_path)
     subprocess.check_call("echo 0 >> count.txt", shell=True, cwd=self.local_path)
     subprocess.check_call("git add count.txt", shell=True, cwd=self.local_path)
     subprocess.check_call("git commit -m modified-0", shell=True, cwd=self.local_path)
     # produce many tags to make git log command fail if all are added
     for count in range(4000):
         subprocess.check_call("git tag modified-%s" % count, shell=True, cwd=self.local_path)
     po = subprocess.Popen("git log -n 1 --pretty=format:\"%H\"", shell=True, cwd=self.local_path, stdout=subprocess.PIPE)
     self.last_version = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')
开发者ID:esteve,项目名称:vcstools,代码行数:12,代码来源:test_git.py


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