tibdex / github-cherry-pick Goto Github PK
View Code? Open in Web Editor NEW๐ Cherry-pick several commits on a branch using the low level Git Data operations provided by the GitHub REST API
License: MIT License
๐ Cherry-pick several commits on a branch using the low level Git Data operations provided by the GitHub REST API
License: MIT License
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.
Not able to require and use function
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.