How to use the dulwich.porcelain 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 briarfox / ShellistaExt / ShellistaExt / plugins / extensions / git / git_plugin.py View on Github external
def git_commit(args):
        if len(args) == 3:
            try:
                repo = _get_repo()
                #print repo.commit(name=args[1],email=args[2],message=args[0])
                author = "{0} <{1}>".format(args[1], args[2])
                print porcelain.commit(repo.repo, args[0], author, author )
            except:
                print 'Error: {0}'.format(sys.exc_value)
        else:
            print command_help['commit']
github khilnani / pythonista-scripts / thirdparty / GitHub Tools / gitview / gitui.py View on Github external
def delact(sender):
            porcelain.rm(self._repo(),[str(self.list[section][row])])
            self.refresh()
            console.hud_alert('del {} {}'.format(section,row))
        def unstage(sender):
github yoda-pa / yoda / modules / git.py View on Github external
def process(input):
    gh_username = setup.get_gh_username()
    gh_password = setup.decrypt_password()
    gh = github.Github(gh_username, gh_password)
    click.echo(chalk.blue('you are in git module'))
    click.echo('input = %s' % input)
    USER_CONFIG_FILE_PATH = get_config_file_paths()['USER_CONFIG_FILE_PATH']
    USER_CONFIG_FOLDER_PATH = get_folder_path_from_file_path(USER_CONFIG_FILE_PATH)
    repo = porcelain.init(USER_CONFIG_FOLDER_PATH)
    porcelain.add(repo)
    porcelain.commit(repo, "A sample commit")
    porcelain.remote_add(repo, ".yoda", "https://github.com/manparvesh/.yoda")
    porcelain.push(repo, "https://github.com/manparvesh/.yoda")
github ywangd / stash / lib / git / git-merge.py View on Github external
print 'Fast forwarding {} to {}'.format(repo.active_branch,merge_head)
        repo.refs['HEAD']=merge_head
        return 
    if base_sha == merge_head:
        print 'head is already up to date'
        return  
    
    print 'merging <{}> into <{}>\n{} commits ahead of merge base <{}> respectively'.format(merge_head[0:7],head[0:7],count_commits_between(repo,merge_head,head),base_sha[0:7])
    base_tree=repo[base_sha].tree
    merge_head_tree=repo[merge_head].tree
    head_tree=repo[head].tree

    num_conflicts,added,removed=merge_trees(repo.repo.object_store, base_tree,head_tree,merge_head_tree)
    # update index
    if added: 
        porcelain.add(repo.path, added)
    if removed: 
        porcelain.rm(repo.path, removed)

    repo.repo._put_named_file('MERGE_HEAD',merge_head)
    repo.repo._put_named_file('MERGE_MSG','Merged from {}({})'.format(merge_head, result.commit))
    print 'Merge complete with {} conflicted files'.format(num_conflicts)
    print '''Merged files were added to the staging area, but have not yet been comitted.   
    Review changes (e.g.   git diff   or   git diff>changes.txt; edit changes.txt    ), and 
    resolve any conflict markers before comitting.  
    
    Use   git add     on any files updated after resolving conflicts.  
    Run   git commit  to complete the merge process.
    
    '''
github openstack / reno / reno / scanner.py View on Github external
for fname in d_index.get_unstaged_changes(index, self.reporoot):
                fname = fname.decode('utf-8')
                LOG.debug('found unstaged file %s', fname)
                if fname.startswith(prefix) and _note_file(fname):
                    fullpath = os.path.join(self.reporoot, fname)
                    if os.path.exists(fullpath):
                        LOG.debug('found file %s', fullpath)
                        tracker.add(fname, None, '*working-copy*')
                    else:
                        LOG.debug('deleted file %s', fullpath)
                        tracker.delete(fname, None, '*working-copy*')

            # Pretend anything in the index is part of the fake
            # version "*working-copy*".
            LOG.debug('scanning staged schanges')
            changes = porcelain.get_tree_changes(self._repo)
            for fname in changes['add']:
                fname = fname.decode('utf-8')
                if fname.startswith(prefix) and _note_file(fname):
                    tracker.add(fname, None, '*working-copy*')
            for fname in changes['modify']:
                fname = fname.decode('utf-8')
                if fname.startswith(prefix) and _note_file(fname):
                    tracker.modify(fname, None, '*working-copy*')
            for fname in changes['delete']:
                fname = fname.decode('utf-8')
                if fname.startswith(prefix) and _note_file(fname):
                    tracker.delete(fname, None, '*working-copy*')

        aggregator = _ChangeAggregator()

        # Process the git commit history.
github gruns / gitauthors / gitauthors / gitauthors.py View on Github external
def gitauthors(repoUrl):
    lines = []

    with temporaryDirectory() as repo:
        with open(os.devnull, 'wb') as devnull:
            porcelain.clone(repoUrl, repo, errstream=devnull)

        authors = getRepositoryAuthors(repo)

        longestNameLen = max(len(t[0]) for _, t in authors)
        longestEmailLen = max(len(email) for email, _ in authors)
        longestCommitsLen = max(len(str(t[1])) for _, t in authors)

        fmt = '{0:%i}  {1:<%i}  {2:>%i} %%s last on {3}'
        fmt = fmt % (longestNameLen, longestEmailLen, longestCommitsLen)
        for email, (name, numCommits, latestCommitDate) in authors:
            tmp = fmt % ('commit, ' if numCommits == 1 else 'commits,')
            lines.append(tmp.format(name, email, numCommits, latestCommitDate))

    return os.linesep.join(lines)
github aws-quickstart / taskcat / taskcat / _cli_modules / deploy.py View on Github external
def _git_clone(url, path):
        outp = BytesIO()
        if path.exists():
            # TODO: handle updating existing repo
            LOG.warning(
                "path already exists, updating from remote is not yet implemented"
            )
            # shutil.rmtree(path)
        if not path.exists():
            path.mkdir(parents=True)
            porcelain.clone(
                url, str(path), checkout=True, errstream=outp, outstream=outp
            )
        LOG.debug(outp.getvalue().decode("utf-8"))
github Pext / Pext / pext / __main__.py View on Github external
    @staticmethod
    def update(directory: str) -> bool:
        """If an update is available, attempt to update the git-managed directory."""
        # Get current commit
        with UpdateManager._path_to_repo(directory) as repo:
            old_commit = repo[repo.head()]

            # Update
            remote_url = UpdateManager.fix_git_url_for_dulwich(UpdateManager.get_remote_url(directory))
            porcelain.pull(repo, remote_url)

            # See if anything was updated
            return old_commit != repo[repo.head()]