Git Product home page Git Product logo

ghpick's Introduction

ghpick

Github Cherry Picker

Create and commit cherry-pick patches over the Github API

Why

I had a need. I needed to perform cherry-pick patch deliveries without having a working copy. The Github API is fantastic and feature rich, but this is probably a feature they ought not support.

How

  from ghpick.cherry import CherryPick
  from ghpick.engine import GithubMergeConflict
  
  ## For standard users:
  cherry = CherryPick(
      username='ima_user',
      password='ima_pass',
      org='ima_user',
      repo='ghpick')
  ## For enterprise users:
  cherry = CherryPick(
      username='ima_user',
      password='ima_pass',
      org='MyTeam',
      repo='MyRepo',
      base_url='https://github.mycompany.com/api/v3')
  try:
    cherry.patch(
        base_sha='7a23...full-sha',
        target_sha='82aa1...full-sha',
        target_branch='integration_branch_1')
  except GithubMergeConflict as e:
    send_email(to=developer, message="Conflicts: {}".format(e))
  else:
    commit = cherry.commit()
    print "Commit SHA: {}".format(commit['sha'])

Those SHAs you pass in to the patch method can be tags, complete SHAs, or a branch name. If you choose a branch name then it will resolve to the HEAD of that branch.

If you don't pass "message" to the commit method a reasonable default is chosen. You could take advantage of the commits method in the engine to get the list of commits in a range and create a comprehensive message:

  commits = cherry.engine.commits('7a2b...full-sha','822b...full-sha')
  message = '\n\n'.join([ c['commit']['message'] for c in commits ])
  cherry.commit(message=message)

Installation

  pip install ghpick

Requirements

  • git must be installed. The command used to patch the files is "git apply"

Todo

The tests need to be rewritten.

Warnings

As always, use this library at your own risk. Plese test this in your environment before letting it run free since this rebuilds the tree. You can always revert if something goes wrong.

Please

Please file issues if you need, or feel free to email me with any questions. Pull requests are welcome.

ghpick's People

Contributors

shiqiyang-okta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.