How to use the dulwich.porcelain.push 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 ywangd / stash / bin / git.py View on Github external
outstream = StringIO()
    if user:
        if not pw and SAVE_PASSWORDS:
            pw = keychain.get_password(keychainservice, user)

        #Check again, did we retrieve a password?
        if not pw:
            user, pw = console.login_alert('Enter credentials for {0}'.format(netloc), login=user)
        host_with_auth = '{}:{}@{}'.format(user, pw, netloc)
        url = urlunparse(urlparse(result.url)._replace(netloc=host_with_auth))
        porcelain.push(repo.repo.path, url, branch_name, errstream=outstream)
        keychain.set_password(keychainservice, user, pw)

    else:
        porcelain.push(repo.repo.path, result.url, branch_name, errstream=outstream)

    for line in outstream.getvalue().split('\n'):
        print((line.replace(pw, '*******') if pw else line))

    print('success!')
github raboof / serverless-wiki / edit.py View on Github external
def update_git(page, new_md, username, user):
  filename = "/tmp/source/%s.md" % page
  with open(filename, "w") as text_file:
    text_file.write(new_md)

  porcelain.add('/tmp/source', filename)

  author = user.get_string('full_name') + ' <' + username + '@invalid>'
  committer = 'lambda '
  print('committing')
  porcelain.commit('/tmp/source', "Page '%s' updated" % page, author=author, committer=committer)
  print('pushing')
  porcelain.push('/tmp/source', os.environ['SOURCE_GIT_URL'], 'refs/heads/master')
  print('pushed')
github dcos / dcos-e2e / admin / release.py View on Github external
def commit_and_push(
    version: str,
    repository: Repository,
    paths: List[Path],
) -> None:
    """
    Commit and push all changes.
    """
    local_repository = Repo('.')
    _, ignored = add(paths=[str(path) for path in paths])
    assert not ignored
    message = b'Update for release ' + version.encode('utf-8')
    commit(message=message)
    branch_name = 'master'
    push(
        repo=local_repository,
        remote_location=repository.ssh_url,
        refspecs=branch_name.encode('utf-8'),
    )
github khilnani / pythonista-scripts / thirdparty / GitHub Tools / gitview / gitui.py View on Github external
def push_callback(user,pw):
            print  "Attempting to push to: {0}, branch: {1}".format(remote, branch_name)
            console.show_activity()
            if user:
               try:
                  parsedurl=urlparse.urlparse(remote)
                  host_with_auth='{}:{}@{}'.format( 
                                  user,pw,parsedurl.netloc)
                  url=urlparse.urlunparse(
                      parsedurl._replace( netloc=host_with_auth))
                  porcelain.push(repo.path, url, branch_name)
                  keychain.set_password(keychainservice, user, pw)
               except urllib2.URLError:
                  console.hide_activity()
                  console.hud_alert('push failed','error')
                  return
            else:
                porcelain.push(repo.repo, result.url, branch_name)
            console.hide_activity()
            console.hud_alert('push complete')
        def push_callback_dict(d):
github briarfox / ShellistaExt / ShellistaExt / plugins / extensions / git / git_plugin.py View on Github external
user = dict(keychain.get_services())[keychainservice]
            except KeyError:
                user, pw = console.login_alert('Enter credentials for {0}'.format(netloc))

        if user:
            if not pw and SAVE_PASSWORDS:
                pw = keychain.get_password(keychainservice, user)

            #Check again, did we retrieve a password?
            if not pw:
                user, pw = console.login_alert('Enter credentials for {0}'.format(netloc), login=user)
                #pw = getpass.getpass('Enter password for {0}: '.format(user))

            opener = auth_urllib2_opener(None, result.url, user, pw)

            print porcelain.push(repo.repo, result.url, branch_name, opener=opener)
            keychain.set_password(keychainservice, user, pw)

        else:
            print porcelain.push(repo.repo, result.url, branch_name)
github khilnani / pythonista-scripts / thirdparty / GitHub Tools / gitview / gitui.py View on Github external
console.show_activity()
            if user:
               try:
                  parsedurl=urlparse.urlparse(remote)
                  host_with_auth='{}:{}@{}'.format( 
                                  user,pw,parsedurl.netloc)
                  url=urlparse.urlunparse(
                      parsedurl._replace( netloc=host_with_auth))
                  porcelain.push(repo.path, url, branch_name)
                  keychain.set_password(keychainservice, user, pw)
               except urllib2.URLError:
                  console.hide_activity()
                  console.hud_alert('push failed','error')
                  return
            else:
                porcelain.push(repo.repo, result.url, branch_name)
            console.hide_activity()
            console.hud_alert('push complete')
        def push_callback_dict(d):
github jsbain / gitview / gitui.py View on Github external
console.show_activity()
            if user:
               try:
                  parsedurl=urlparse.urlparse(remote)
                  host_with_auth='{}:{}@{}'.format( 
                                  user,pw,parsedurl.netloc)
                  url=urlparse.urlunparse(
                      parsedurl._replace( netloc=host_with_auth))
                  porcelain.push(repo.path, url, branch_name)
                  keychain.set_password(keychainservice, user, pw)
               except urllib2.URLError:
                  console.hide_activity()
                  console.hud_alert('push failed','error')
                  return
            else:
                porcelain.push(repo.repo, result.url, branch_name)
            console.hide_activity()
            console.hud_alert('push complete')
        def push_callback_dict(d):