How to use the dulwich.repo.Repo.init function in dulwich

To help you get started, we’ve selected a few dulwich examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akbargumbira / qgis_resources_sharing / ext_libs / dulwich / contrib / test_swift_smoke.py View on Github external
def test_push_data_branch(self):
        def determine_wants(*args):
            return {"refs/heads/master": local_repo.refs["HEAD"]}
        local_repo = repo.Repo.init(self.temp_d, mkdir=True)
        os.mkdir(os.path.join(self.temp_d, "dir"))
        files = ('testfile', 'testfile2', 'dir/testfile3')
        i = 0
        for f in files:
            open(os.path.join(self.temp_d, f), 'w').write("DATA %s" % i)
            i += 1
        local_repo.stage(files)
        local_repo.do_commit('Test commit', 'fbo@localhost',
                             ref='refs/heads/master')
        swift.SwiftRepo.init_bare(self.scon, self.conf)
        tcp_client = client.TCPGitClient(self.server_address,
                                         port=self.port)
        tcp_client.send_pack(self.fakerepo,
                             determine_wants,
                             local_repo.object_store.generate_pack_data)
        swift_repo = swift.SwiftRepo("fakerepo", self.conf)
github dulwich / dulwich / dulwich / contrib / test_swift_smoke.py View on Github external
def test_push_multiple_branch(self):
        def determine_wants(*args):
            return {"refs/heads/mybranch":
                    local_repo.refs["refs/heads/mybranch"],
                    "refs/heads/master":
                    local_repo.refs["refs/heads/master"],
                    "refs/heads/pullr-108":
                    local_repo.refs["refs/heads/pullr-108"]}

        local_repo = repo.Repo.init(self.temp_d, mkdir=True)
        # Nothing in the staging area
        local_shas = {}
        remote_shas = {}
        for branch in ('master', 'mybranch', 'pullr-108'):
            local_shas[branch] = local_repo.do_commit(
                'Test commit %s' % branch, 'fbo@localhost',
                ref='refs/heads/%s' % branch)
        swift.SwiftRepo.init_bare(self.scon, self.conf)
        tcp_client = client.TCPGitClient(self.server_address,
                                         port=self.port)
        tcp_client.send_pack(self.fakerepo,
                             determine_wants,
                             local_repo.object_store.generate_pack_data)
        swift_repo = swift.SwiftRepo("fakerepo", self.conf)
        for branch in ('master', 'mybranch', 'pullr-108'):
            remote_shas[branch] = swift_repo.refs.read_loose_ref(
github Yelp / paasta / general_itests / steps / deployments_json_steps.py View on Github external
def step_impl_given(context):
    context.test_git_repo_dir = tempfile.mkdtemp("paasta_tools_deployments_json_itest")
    context.test_git_repo = Repo.init(context.test_git_repo_dir)
    paasta_print("Temp repo in %s" % context.test_git_repo_dir)

    blob = Blob.from_string(b"My file content\n")
    tree = Tree()
    tree.add(b"spam", 0o0100644, blob.id)

    commit = Commit()
    commit.author = commit.committer = b"itest author"
    commit.commit_time = commit.author_time = int(time())
    commit.commit_timezone = commit.author_timezone = parse_timezone(b"-0200")[0]
    commit.message = b"Initial commit"
    commit.tree = tree.id

    object_store = context.test_git_repo.object_store
    object_store.add_object(blob)
    object_store.add_object(tree)
github docker / docker.github.io / contrib / brew / brew / git.py View on Github external
def clone(repo_url, ref=None, folder=None):
    is_commit = False
    if ref is None:
        ref = 'refs/heads/master'
    elif not ref.startswith('refs/'):
        is_commit = True
    logger.debug("clone repo_url={0}, ref={1}".format(repo_url, ref))
    if folder is None:
        folder = tempfile.mkdtemp()
    logger.debug("folder = {0}".format(folder))
    rep = Repo.init(folder)
    client, relative_path = get_transport_and_path(repo_url)
    logger.debug("client={0}".format(client))

    remote_refs = client.fetch(relative_path, rep)
    for k, v in remote_refs.iteritems():
        try:
            rep.refs.add_if_new(k, v)
        except:
            pass

    if is_commit:
        rep['HEAD'] = rep.commit(ref)
    else:
        rep['HEAD'] = remote_refs[ref]
    indexfile = rep.index_path()
    tree = rep["HEAD"].tree
github chrisparnin / autogit / Sublime Text / autogit.py View on Github external
def init(self,path):
		#pygit2.init_repository(path, False)
		if( not os.path.isdir( path ) ):
			os.makedirs(path)
		Repo.init(path)
github tgalal / inception / inception / config / configtreeparser.py View on Github external
remoteUrl = None

                if not remoteUrl:
                    raise ValueError("Repo \"%s\" not configured or has no remote url" % targetPath)

                if repoUrl and repoUrl != remoteUrl:
                    print("Error: Supplied remote URL does not match remote url in repo config!")
                    sys.exit(1)

            except dulwich.errors.NotGitRepository:
                print("Error: %s will be overwritten, delete or move it." % targetPath)
                sys.exit(1)
        else:
            remoteUrl = repoUrl
            os.makedirs(targetPath)
            localRepo = Repo.init(targetPath)

        remoteUrl = str(remoteUrl)

        logger.info("Syncing %s to %s" % (remoteUrl, targetPath))

        client, hostPath = get_transport_and_path(remoteUrl)
        try:
            remoteRefs = client.fetch(hostPath, localRepo)
            logger.info("Synced %s to %s" % (remoteUrl, targetPath))
            localRepo["HEAD"] = remoteRefs["HEAD"]
            localRepo.reset_index()

            config = localRepo.get_config()
            config.set(("remote", "origin"), "url", remoteUrl)
            config.write_to_path()
github akbargumbira / qgis_resources_sharing / ext_libs / dulwich / porcelain.py View on Github external
def init(path=".", bare=False):
    """Create a new git repository.

    :param path: Path to repository.
    :param bare: Whether to create a bare repository.
    :return: A Repo instance
    """
    if not os.path.exists(path):
        os.mkdir(path)

    if bare:
        return Repo.init_bare(path)
    else:
        return Repo.init(path)
github datastore / datastore / datastore / core / impl / git.py View on Github external
def init(self):
    '''Create an empty git repository or reinitialize an existing one'''
    gitdir = os.path.join(self.path, '.git')
    if os.path.isdir(gitdir):
      self.repo = dulwich.repo.Repo(self.path)
    else:
      self.repo = dulwich.repo.Repo.init(self.path)