Coder Social home page Coder Social logo

tibdex / github-cherry-pick Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 6.0 241 KB

๐Ÿ’ Cherry-pick several commits on a branch using the low level Git Data operations provided by the GitHub REST API

License: MIT License

JavaScript 2.45% TypeScript 97.55%
cherry-pick git github github-rest-v3

github-cherry-pick's People

Contributors

erickzhao avatar tibdex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

github-cherry-pick's Issues

Merge conflicts not handled

I am interested in solving the problem of cherry-picking using Github's low-level API, too, however in Golang programming language.

I just read the Git Internals chapter of the Pro Git book (great!) and one thing I note is that creating commits using the low-level "plumbing" API does not work with diff/patch but with file content/trees. As such, creating commits by referring to trees using the low-level Github API is not the same as doing a git cherry-pick XXX as it wont handle merge conflicts at all. It is something close to git cherry-pick -Xtheirs XXX with the difference that the new commit XXX will modify the file to look exactly as it looked at commit XXX. Really what you want to do is to extract the diff from XXX^ to XXX, create a new tree based on that and then create a commit.

Are you handling this? I'm by no means a TypeScript expert, but from what I understand in https://github.com/tibdex/github-cherry-pick/blob/master/src/index.ts you are not. Have you considered how to handle it? One way of doing it would be to iteratively do something (in pseudo code)

foreach commit in commit_list:
    newtree = commit.tree
    foreach filediff in commit.modified_files:
        # https://developer.github.com/v3/git/trees/#create-a-tree
        newtree = create_tree(from=newtree, file_content=apply_diff(commit.previous, filediff))

# https://developer.github.com/v3/git/commits/#create-a-commit
create_new_commit(from, newtree)

I understand it would be slower, but it's the correct way of doing it, I think.

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.