• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pygit2.init_repository函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: init_repo

def init_repo(repo_path, clone_from=None, clone_refs=False,
              alternate_repo_paths=None, is_bare=True):
    """Initialise a new git repository or clone from existing."""
    assert is_valid_new_path(repo_path)
    init_repository(repo_path, is_bare)

    if clone_from:
        # The clone_from's objects and refs are in fact cloned into a
        # subordinate tree that's then set as an alternate for the real
        # repo. This lets git-receive-pack expose available commits as
        # extra haves without polluting refs in the real repo.
        sub_path = os.path.join(repo_path, 'turnip-subordinate')
        clone_repository(clone_from, sub_path, True)
        assert is_bare
        alt_path = os.path.join(repo_path, 'objects/info/alternates')
        with open(alt_path, 'w') as f:
            f.write('../turnip-subordinate/objects\n')

        if clone_refs:
            # With the objects all accessible via the subordinate, we
            # can just copy all refs from the origin. Unlike
            # pygit2.clone_repository, this won't set up a remote.
            # TODO: Filter out internal (eg. MP) refs.
            from_repo = Repository(clone_from)
            to_repo = Repository(repo_path)
            for ref in from_repo.listall_references():
                to_repo.create_reference(
                    ref, from_repo.lookup_reference(ref).target)

    if alternate_repo_paths:
        write_alternates(repo_path, alternate_repo_paths)
    ensure_config(repo_path)  # set repository configuration defaults
    return repo_path
开发者ID:Waverbase,项目名称:turnip,代码行数:33,代码来源:store.py


示例2: _init

def _init(victim, str_victim):
    try:
        rmtree(str_victim)
    except OSError:
        pass
    victim.mkdir()
    init_repository(str_victim)
开发者ID:d910aa14,项目名称:pyrite,代码行数:7,代码来源:a.py


示例3: initial

    def initial(self, prefix):
        """
        Set up the git repo at ``settings.GIT_REPO_PATH``.
        And add initial directory to the repo.

        """
        pygit2.init_repository(self.repo_path, True)  # a bare repository
开发者ID:aleray,项目名称:aa.olga,代码行数:7,代码来源:git2.py


示例4: test_011_storage_empty_basic

    def test_011_storage_empty_basic(self):
        emptydir = join(self.testdir, 'empty')

        init_repository(join(emptydir, '.git'), bare=True)

        item = DummyItem(emptydir)
        storage = GitStorage(item)
        self.assertEqual(storage.files(), [])

        pathinfo = storage.pathinfo('')
        self.assertEqual(pathinfo, {
            'basename': '',
            'date': '',
            'size': 0,
            'type': 'folder',
        })

        result = list(storage.listdir(''))
        self.assertEqual(result, [])

        result = storage.log(None, 1)
        self.assertEqual(result, [])

        self.assertEqual(storage.shortrev, None)
        self.assertEqual(storage.rev, None)
开发者ID:repodono,项目名称:repodono.backend_git,代码行数:25,代码来源:test_utility.py


示例5: repositories

def repositories():
    if request.method == 'POST':
        username = 'baijian'
        reponame = request.form['reponame']
        repodesc = request.form['repodesc']
        init_repository('/home/git/repositories/' + username + '/' + reponame, True)
        return redirect(url_for('.index', name=username, reponame=reponame))
开发者ID:baijian,项目名称:gitjoy,代码行数:7,代码来源:views.py


示例6: init_backend

 def init_backend(cls, path, fields, init=False, soft=False):
     # Metadata database
     init_repository('{0}/database'.format(path), bare=False)
     lfs.make_folder('{0}/database/.git/patchs'.format(path))
     cls.init_backend_static(path)
     # Make catalog
     make_catalog('{0}/catalog'.format(path), fields)
开发者ID:hforge,项目名称:itools,代码行数:7,代码来源:git.py


示例7: prepare_backup_folder

  def prepare_backup_folder(self):
    print("Preparing backup folder : ", self.container)
    os.mkdir(self.container)
    pygit2.init_repository(self.container, False)

    # look for the restore script in the default install dir first
    try:
      shutil.copy2("/usr/share/pacbackup/pacrestore.sh", self.container)
    except FileNotFoundError:
      try:
        shutil.copy2(os.path.join(os.path.dirname(os.path.realpath(__file__)),
          "pacrestore.sh"), self.container)
      except FileNotFoundError:
        print("Couldn't find the restore script anywhere, try reinstalling", file=stderr)
        shutil.rmtree(self.container)
        exit()

    repo = pygit2.Repository(self.container)
    index = repo.index

    index.read()
    index.add_all()
    index.write()
    tree = index.write_tree()

    message = "Initial Commit - Automated Package List Backup"
    comitter = pygit2.Signature('PacBackup '+__version__, '')
    sha = repo.create_commit('HEAD', 
      comitter, comitter, message, 
      tree, 
      [])
开发者ID:xguse,项目名称:pacbackup,代码行数:31,代码来源:pacbackup.py


示例8: init

 def init(self):
     pygit2.init_repository(self.dir)
     os.makedirs(self.md_path)
     os.makedirs(self.generate_path)
     self.config = config.Config(self.dir)
     for file in resources.INIT_FILES:
         with open(os.path.join(self.dir, file), "w+") as f:
             f.write(resources.INIT_FILES[file])
开发者ID:rshipp,项目名称:sundara,代码行数:8,代码来源:sundara.py


示例9: __init__

 def __init__(self, path):
     # TODO path should probably be a resource, ie redis url etc.
     self.path = path
     self.object_root = os.path.join(self.path, "objects")
     if not os.path.exists(self.object_root):
         log.info("initializing database in %s" % (path))
         pygit2.init_repository(path, True)
     self.repo = pygit2.Repository(path)
     self.check_repo_sanity()
开发者ID:Byzantium,项目名称:groundstation,代码行数:9,代码来源:git_store.py


示例10: initialise

    def initialise(self, new_remote=None):
        """Setup the .git folder, with optional remote"""
        log.info("Setting up a .git folder")
        git_folder = os.path.join(self.location, ".git")
        if os.path.exists(git_folder):
            raise GitError("Trying to initialise git, but .git folder already exists", location=self.location)

        pygit2.init_repository(self.location)
        self.add_change("Initial commit", changed_files=True)
        if new_remote:
            self.change_remote(new_remote)
开发者ID:cgspeck,项目名称:credo,代码行数:11,代码来源:git.py


示例11: setUp

 def setUp(self):
     self.repo_path = mkdtemp()
     init_repository(self.repo_path, False)
     self.repo = Repository(self.repo_path)
     self.file_name = 'foo.rst'
     self.file_path = os.path.join(self.repo_path, self.file_name)
     with codecs.open(self.file_path, 'w', encoding='utf-8') as fp:
         fp.write('test\n')
     self.tree = self.repo.TreeBuilder()
     self.last_commit = git_commit(self.repo, self.tree, [self.file_name])
     self.changectx = self.repo.head
开发者ID:GoGoBunny,项目名称:blohg,代码行数:11,代码来源:filectx.py


示例12: setUp

    def setUp(self):

        self.dir = TemporaryDirectory()
        self.remotedir = TemporaryDirectory()
        self.file = NamedTemporaryFile(dir=self.dir.name, delete=False)
        self.filename = path.basename(self.file.name)
        self.author = Signature('QuitStoreTest', '[email protected]')
        self.comitter = Signature('QuitStoreTest', '[email protected]')

        # Initialize repository
        init_repository(self.dir.name, False)
开发者ID:AKSW,项目名称:QuitStore,代码行数:11,代码来源:test_git.py


示例13: create_projects_git

def create_projects_git(folder, bare=False):
    """ Create some projects in the database. """
    repos = []
    for project in ['test.git', 'test2.git']:
        repo_path = os.path.join(folder, project)
        repos.append(repo_path)
        if not os.path.exists(repo_path):
            os.makedirs(repo_path)
        pygit2.init_repository(repo_path, bare=bare)

    return repos
开发者ID:denys-duchier,项目名称:pagure,代码行数:11,代码来源:__init__.py


示例14: create_storage

    def create_storage(cls, path):
        """
            Create repository, and return GitStorage object on it

            :param path: Absolute path to the Git repository to create.
            :type path: str
            :returns: GitStorage
        """

        init_repository(path, False)

        return cls(path)
开发者ID:9h37,项目名称:django-gitstorage,代码行数:12,代码来源:StorageBackend.py


示例15: create_git_repo

def create_git_repo(name, gitfolder):
    # Create a git project based on the package information.
    # get the path of the git repo
    gitrepo = os.path.join(gitfolder, '%s.git' % name)

    if os.path.exists(gitrepo):
        raise fresque.exceptions.RepoExistsException(
            'The project named "%s" already have '
            'a git repository' % name
        )
    # create a bare git repository
    pygit2.init_repository(gitrepo, bare=True)
    return 'Successfully created Project {0} git respository'.format(name)
开发者ID:ncoghlan,项目名称:fresque,代码行数:13,代码来源:views.py


示例16: _setup_temp_repo

def _setup_temp_repo():
    """
    Set up a temporary Git repository in which to house pack files
    for unpacking into another repository.

    Returns the path to the new .git/objects/pack directory.
    """
    tmpname = 'p4gf_git_tmp'
    tmprepo = os.path.join(os.path.dirname(os.getcwd()), tmpname)
    if os.path.exists(tmprepo):
        shutil.rmtree(tmprepo)
    pygit2.init_repository(tmprepo)
    packdir = os.path.join(tmprepo, '.git', 'objects', 'pack')
    return (tmprepo, packdir)
开发者ID:spearhead-ea,项目名称:git-fusion,代码行数:14,代码来源:p4gf_git.py


示例17: setUp

    def setUp(self):
        # For tests, it's easier to use global_config so that we don't
        # have to pass a config object around.
        from gitmodel.workspace import Workspace
        from gitmodel import exceptions
        from gitmodel import utils

        self.exceptions = exceptions
        self.utils = utils

        # Create temporary repo to work from
        self.repo_path = tempfile.mkdtemp(prefix='python-gitmodel-')
        pygit2.init_repository(self.repo_path, False)
        self.workspace = Workspace(self.repo_path)
开发者ID:WnP,项目名称:python-gitmodel,代码行数:14,代码来源:__init__.py


示例18: setUp

    def setUp(self):
        self.repo_path = mkdtemp()
        init_repository(self.repo_path, False)
        self.repo = Repository(self.repo_path)

        # create files and commit
        self.sign = Signature('foo', '[email protected]')
        self.repo_files = ['a%i.rst' % i for i in range(5)]
        for i in self.repo_files:
            with codecs.open(os.path.join(self.repo_path, i), 'w',
                             encoding='utf-8') as fp:
                fp.write('dumb file %s\n' % i)
        self.tree = self.repo.TreeBuilder()
        self.old_commit = git_commit(self.repo, self.tree, self.repo_files)
开发者ID:GoGoBunny,项目名称:blohg,代码行数:14,代码来源:changectx.py


示例19: setup_git_repo

    def setup_git_repo(self):
        """ Create a basic git repo withing the tests folder that can be used
        then for the tests.
        """

        # Create a bare git repo
        bare_repo_path = os.path.join(self.gitroot, 'test_repo.git')
        os.makedirs(bare_repo_path)
        pygit2.init_repository(bare_repo_path, bare=True)

        # Clone the bare git repo and add the elements we need in it
        git_repo_path = os.path.join(self.gitroot, 'test_repo')
        pygit2.clone_repository(bare_repo_path, git_repo_path, bare=False)

        repo = pygit2.Repository(git_repo_path)

        # Add basic files needed
        open(os.path.join(git_repo_path, '.gitignore'), 'w').close()
        repo.index.add('.gitignore')
        open(os.path.join(git_repo_path, 'sources'), 'w').close()
        repo.index.add('sources')
        repo.index.write()

        with open(os.path.join(
                git_repo_path, '.git', 'config'), 'a') as stream:
            stream.write(GITCONFIG)

        # Commits the files added
        tree = repo.index.write_tree()
        author = pygit2.Signature(
            'Alice Author', '[email protected]')
        committer = pygit2.Signature(
            'Cecil Committer', '[email protected]')
        repo.create_commit(
            'refs/heads/master',  # the name of the reference to update
            author,
            committer,
            'Add basic file required',
            # binary string representing the tree object ID
            tree,
            # list of binary strings representing parents of the new commit
            []
        )

        # Push to the remote repo
        master_ref = repo.lookup_reference('HEAD').resolve()
        refname = '%s:%s' % (master_ref.name, master_ref.name)
        ori_remote = repo.remotes[0]
        ori_remote.push(refname)
开发者ID:fedora-infra,项目名称:pygit2_utils,代码行数:49,代码来源:__init__.py


示例20: save

    def save(
            self, force_insert=False, force_update=False, using=None,
            update_fields=None):
        """ Save model and init git repository.

        :return Model: A saved instance

        """
        new = False if self.pk else True
        obj = super(Repository, self).save(
            force_insert, force_update, using, update_fields)
        if new:
            from pygit2 import init_repository
            # Initiate bare repository on server
            init_repository(self.absolute_path, bare=True)
        return obj
开发者ID:emil2k,项目名称:joltem,代码行数:16,代码来源:models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pygit2.Repository类代码示例发布时间:2022-05-25
下一篇:
Python pygit2.discover_repository函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap