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


Python GitRepository.create方法代码示例

本文整理汇总了Python中gbp.git.repository.GitRepository.create方法的典型用法代码示例。如果您正苦于以下问题:Python GitRepository.create方法的具体用法?Python GitRepository.create怎么用?Python GitRepository.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gbp.git.repository.GitRepository的用法示例。


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

示例1: setup_module

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
def setup_module():
    """One setup for all tests."""

    ENV["cwd"] = os.getcwd()
    tmp = tempfile.mkdtemp(prefix="test-gbs-changelog-")
    shutil.copy(".gbs.conf", tmp)
    os.chdir(tmp)
    ENV["dir"] = tmp

    # Create git repo
    repo = GitRepository.create(".")
    author = repo.get_author_info()
    ENV["repo"] = repo
    ENV["name"] = author.name
    ENV["email"] = author.email

    # Make 3 commits
    for num in (1, 2, 3):
        with open("file", "w") as fobj:
            fobj.write("content %d" % num)
        time.sleep(1)  # Sleep to make commit timestamps differ
        repo.add_files(repo.path, untracked=True)
        repo.commit_files(files="file", msg="change %d" % num)

    ENV["date"] = datetime.datetime.now().strftime("%a %b %d %Y")
    commits = sorted(repo.get_commits(options=["--pretty=format:%at %H"]), reverse=True)

    ENV["commits"] = [item.split()[-1] for item in commits]
开发者ID:01org,项目名称:gbs,代码行数:30,代码来源:test_changelog.py

示例2: test_initial_import_fail_create_upstream_tag

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
    def test_initial_import_fail_create_upstream_tag(self, RepoMock):
        repo = GitRepository.create(self.pkg)
        os.chdir(self.pkg)
        orig = self._orig('2.6')
        ok_(import_orig(['arg0', '--no-interactive', orig]) == 1)

        self._check_repo_state(repo, None, [], tags=[])
开发者ID:ottok,项目名称:git-buildpackage,代码行数:9,代码来源:test_import_orig.py

示例3: test_guess_spec_repo

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
    def test_guess_spec_repo(self):
        """Test guess_spec_repo() and spec_from_repo() functions"""
        # Create dummy repository with some commits
        repo = GitRepository.create(self.tmpdir)
        with open(os.path.join(repo.path, "foo.txt"), "w") as fobj:
            fobj.write("bar\n")
        repo.add_files("foo.txt")
        repo.commit_all("Add dummy file")
        os.mkdir(os.path.join(repo.path, "packaging"))
        shutil.copy(os.path.join(SPEC_DIR, "gbp-test.spec"), os.path.join(repo.path, "packaging"))
        repo.add_files("packaging/gbp-test.spec")
        repo.commit_all("Add spec file")

        # Spec not found
        with assert_raises(NoSpecError):
            guess_spec_repo(repo, "HEAD~1", recursive=True)
        with assert_raises(NoSpecError):
            guess_spec_repo(repo, "HEAD", recursive=False)
        # Spec found
        spec = guess_spec_repo(repo, "HEAD", "packaging", recursive=False)
        spec = guess_spec_repo(repo, "HEAD", recursive=True)
        eq_(spec.specfile, "gbp-test.spec")
        eq_(spec.specdir, "packaging")
        eq_(spec.specpath, "packaging/gbp-test.spec")

        # Test spec_from_repo()
        with assert_raises(NoSpecError):
            spec_from_repo(repo, "HEAD~1", "packaging/gbp-test.spec")
        spec = spec_from_repo(repo, "HEAD", "packaging/gbp-test.spec")
        eq_(spec.specfile, "gbp-test.spec")
开发者ID:seacoastboy,项目名称:git-buildpackage,代码行数:32,代码来源:20_test_rpm.py

示例4: create_orig_repo

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
    def create_orig_repo(cls, name):
        """Create test repo"""
        repo_path = os.path.join(cls.workdir, name)
        repo = GitRepository.create(repo_path)

        # First, commit sources only and create branch 'sources'
        sources = [src for src in os.listdir(TEST_DATA_DIR)
                       if not src in ['packaging', 'debian']]
        repo.add_files(sources, work_tree=TEST_DATA_DIR)
        repo.commit_staged('Initial version')
        # Make one new commit
        cls.update_repository_file(repo, 'foo.txt', 'new data\n')
        repo.create_branch('source')

        # Create branch with rpm packaging only
        repo.add_files('packaging', work_tree=TEST_DATA_DIR)
        repo.commit_staged('Add rpm packaging files')
        repo.create_branch('rpm')

        # Master has both debian and rpm packaging
        repo.add_files('debian', work_tree=TEST_DATA_DIR)
        repo.commit_staged('Add debian packaging files')

        # Create branch with deb packaging only
        repo.create_branch('deb', 'source')
        repo.set_branch('deb')
        repo.add_files('debian', work_tree=TEST_DATA_DIR)
        repo.commit_staged('Add deb packaging files')

        repo.set_branch('master')
        repo.force_head('master', hard=True)
        return repo
开发者ID:ronan22,项目名称:obs-service-git-buildpackage,代码行数:34,代码来源:__init__.py

示例5: test_guess_spec_repo

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
    def test_guess_spec_repo(self):
        """Test guess_spec_repo() and spec_from_repo() functions"""
        # Create dummy repository with some commits
        repo = GitRepository.create(self.tmpdir)
        with open(os.path.join(repo.path, 'foo.txt'), 'w') as fobj:
            fobj.write('bar\n')
        repo.add_files('foo.txt')
        repo.commit_all('Add dummy file')
        os.mkdir(os.path.join(repo.path, 'packaging'))
        shutil.copy(os.path.join(SPEC_DIR, 'gbp-test.spec'),
                    os.path.join(repo.path, 'packaging'))
        repo.add_files('packaging/gbp-test.spec')
        repo.commit_all('Add spec file')

        # Spec not found
        with assert_raises(NoSpecError):
            guess_spec_repo(repo, 'HEAD~1', recursive=True)
        with assert_raises(NoSpecError):
            guess_spec_repo(repo, 'HEAD', recursive=False)
        # Spec found
        spec = guess_spec_repo(repo, 'HEAD', 'packaging', recursive=False)
        spec = guess_spec_repo(repo, 'HEAD', recursive=True)
        eq_(spec.specfile, 'gbp-test.spec')
        eq_(spec.specdir, 'packaging')
        eq_(spec.specpath, 'packaging/gbp-test.spec')

        # Test spec_from_repo()
        with assert_raises(NoSpecError):
            spec_from_repo(repo, 'HEAD~1', 'packaging/gbp-test.spec')
        spec = spec_from_repo(repo, 'HEAD', 'packaging/gbp-test.spec')
        eq_(spec.specfile, 'gbp-test.spec')
开发者ID:andrewlukoshko,项目名称:git-buildpackage,代码行数:33,代码来源:20_test_rpm.py

示例6: test_running_from_git_tree

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
 def test_running_from_git_tree(self, srcrpm):
     """Test running gbs import from git tree."""
     # Create empty git repo
     repo = GitRepository.create("./repo_dir")
     os.chdir(repo.path)
     eq_(GBS(argv=["gbs", "import", srcrpm]), None)
     eq_(repo.get_local_branches(), ['master', 'pristine-tar', 'upstream'])
     eq_(repo.get_tags(), ['upstream/0.2.29', 'vendor/0.2.29-2.5'])
开发者ID:01org,项目名称:gbs,代码行数:10,代码来源:test_import.py

示例7: test_download

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
 def test_download(self):
     """Test that importing via download works"""
     repo = GitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._download_url('2.6')
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0)
     self._check_repo_state(repo, 'master', self.def_branches,
                            tags=['upstream/2.6'])
开发者ID:marquiz,项目名称:git-buildpackage-rpm,代码行数:10,代码来源:test_import_orig.py

示例8: test_initial_import

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
 def test_initial_import(self):
     """Test that importing into an empty repo works"""
     repo = GitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._orig('2.6')
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0)
     self._check_repo_state(repo, 'master', self.def_branches,
                            tags=['upstream/2.6'])
开发者ID:marquiz,项目名称:git-buildpackage-rpm,代码行数:10,代码来源:test_import_orig.py

示例9: test_initial_import_fail_create_debian_branch

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
    def test_initial_import_fail_create_debian_branch(self):
        repo = GitRepository.create(self.pkg)
        os.chdir(self.pkg)
        orig = self._orig('2.6')

        with patch('gbp.git.repository.GitRepository.create_branch',
                   side_effect=GitRepositoryError('this is a create branch error mock')):
            ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)

        self._check_repo_state(repo, None, [], tags=[])
开发者ID:ottok,项目名称:git-buildpackage,代码行数:12,代码来源:test_import_orig.py

示例10: test_initial_import_fail_create_upstream_tag

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
    def test_initial_import_fail_create_upstream_tag(self, RepoMock):
        """
        Test that we can rollback from a failure to create the upstream
        tag on initial import
        """
        repo = GitRepository.create(self.pkg)
        os.chdir(repo.path)
        orig = self._orig('2.6')
        ok_(import_orig(['arg0', '--no-interactive', orig]) == 1)

        self._check_repo_state(repo, None, [], tags=[])
开发者ID:marquiz,项目名称:git-buildpackage-rpm,代码行数:13,代码来源:test_import_orig.py

示例11: test_update

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
    def test_update(self):
        repo = GitRepository.create(self.pkg)
        os.chdir(self.pkg)

        dsc = self._dsc('2.6-2')
        ok_(import_dsc(['arg0', '--pristine-tar', dsc]) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'])

        self._orig('2.8')
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6'])
开发者ID:ottok,项目名称:git-buildpackage,代码行数:13,代码来源:test_import_orig.py

示例12: test_tag_exists

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
 def test_tag_exists(self):
     """Test that importing an already imported version fails"""
     repo = GitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._orig('2.6')
     # First import
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0)
     heads = self.rem_refs(repo, self.def_branches)
     # Second import must fail
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)
     self._check_log(0, "gbp:error: Upstream tag 'upstream/2.6' already exists")
     # Check that the second import didn't change any refs
     self.check_refs(repo, heads)
开发者ID:ottok,项目名称:git-buildpackage,代码行数:15,代码来源:test_import_orig.py

示例13: test_import_in_submodule

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
 def test_import_in_submodule(self, repo):
     """
     Test that importing works if repo is a git submodule (#674015)
     """
     parent_repo = GitRepository.create('../parent')
     parent_repo.add_submodule(repo.path)
     parent_repo.update_submodules(init=True, recursive=True)
     submodule = GitRepository(os.path.join(parent_repo.path,
                                            'hello-debhelper'))
     ok_(submodule.path.endswith, 'parent/hello-debhelper')
     os.chdir(submodule.path)
     orig = self._orig('2.8')
     submodule.create_branch('upstream', 'origin/upstream')
     ok_(import_orig(['arg0', '--no-interactive', orig]) == 0)
开发者ID:marquiz,项目名称:git-buildpackage-rpm,代码行数:16,代码来源:test_import_orig.py

示例14: test_empty_repo

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
 def test_empty_repo(self):
     """Make sure we can import into an empty repository"""
     dsc = self._dsc30('2.6-2')
     repo = GitRepository.create("hello-debhelper")
     self._check_repo_state(repo, None, [])
     os.chdir('hello-debhelper')
     assert import_dsc(['arg0',
                        '--verbose',
                        '--no-pristine-tar',
                        '--debian-branch=pk4',
                        '--upstream-branch=upstream',
                        dsc]) == 0
     self._check_repo_state(repo, 'pk4', ['pk4', 'upstream'])
     commits, expected = len(repo.get_commits()), 2
     ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
开发者ID:agx,项目名称:git-buildpackage,代码行数:17,代码来源:test_import_dsc.py

示例15: create_orig_repo

# 需要导入模块: from gbp.git.repository import GitRepository [as 别名]
# 或者: from gbp.git.repository.GitRepository import create [as 别名]
 def create_orig_repo(cls, name):
     """Create test repo"""
     orig_repo = GitRepository.create(os.path.join(cls.workdir, name))
     # First, add everything else except for packaging
     files = os.listdir(TEST_DATA_DIR)
     files.remove('packaging')
     orig_repo.add_files(files, work_tree=TEST_DATA_DIR)
     orig_repo.commit_staged('Initial version')
     # Then, add packaging files
     orig_repo.add_files('packaging', work_tree=TEST_DATA_DIR)
     orig_repo.commit_staged('Add packaging files')
     orig_repo.create_tag('v0.1', msg='Version 0.1')
     orig_repo.force_head('master', hard=True)
     # Make new commit
     cls.update_repository_file(orig_repo, 'foo.txt', 'new data\n')
     return orig_repo
开发者ID:01org,项目名称:obs-service-gbs,代码行数:18,代码来源:test_obs_service_gbs.py


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