github-cherry-pick
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -54,3 +54,3 @@ { | ||
}, | ||
"version": "0.1.9" | ||
"version": "0.1.10" | ||
} |
111
README.md
@@ -27,3 +27,3 @@ [![npm version](https://img.shields.io/npm/v/github-cherry-pick.svg)](https://npmjs.org/package/github-cherry-pick) | ||
octokit, | ||
// The login of the repository owner. | ||
// The username of the repository owner. | ||
owner, | ||
@@ -39,2 +39,20 @@ // The name of the repository. | ||
### Disclaimer | ||
`github-cherry-pick` currently only supports a subset of what `git cherry-pick` offers. | ||
For instance, starting with this Git graph: | ||
``` | ||
* 9232f06 (HEAD -> master) D | ||
| * e926f9d (feature) C | ||
| * d216f82 B | ||
|/ | ||
* 24dfa35 A | ||
``` | ||
Calling `github-cherry-pick` with `['e926f9d']` to only cherry-pick the last commit of the `feature` branch on `master` would also actually apply the changes brought by `d216f82` to `master`. | ||
If you have any suggestions for how to support all the situations handled by `git cherry-pick` by only using endpoints of the GitHub REST API, please create an issue or pull request. | ||
## Troubleshooting | ||
@@ -66,19 +84,18 @@ | ||
git commit --message B | ||
git checkout master | ||
git add C.txt | ||
git commit --message C | ||
git checkout master | ||
git add D.txt | ||
git commit --message D | ||
git checkout feature | ||
--> | ||
``` | ||
* 1d3fb48 (HEAD -> feature) B | ||
| * d706821 (master) D | ||
| * 64046c3 C | ||
* 9232f06 (HEAD -> master) D | ||
| * e926f9d (feature) C | ||
| * d216f82 B | ||
|/ | ||
* 8291506 A | ||
* 24dfa35 A | ||
``` | ||
and we want to cherry-pick `7ab6282` and `cce4008` on the `feature` branch. | ||
and we want to cherry-pick `d216f82` and `e926f9d` on the `master` branch. | ||
@@ -92,47 +109,47 @@ `github-cherry-pick` would then take the following steps: | ||
``` | ||
* 1d3fb48 (HEAD -> temp, feature) B | ||
| * d706821 (master) D | ||
| * 64046c3 C | ||
* 9232f06 (HEAD -> temp, master) D | ||
| * e926f9d (feature) C | ||
| * d216f82 B | ||
|/ | ||
* 8291506 A | ||
* 24dfa35 A | ||
``` | ||
2. Merge `64046c3` on `temp` with [POST /repos/:owner/:repo/merges](https://developer.github.com/v3/repos/merging/#perform-a-merge). | ||
2. Merge `d216f82` on `temp` with [POST /repos/:owner/:repo/merges](https://developer.github.com/v3/repos/merging/#perform-a-merge). | ||
<!-- | ||
git merge 64046c3 | ||
git merge d216f82 | ||
--> | ||
``` | ||
* 6cb4aca (HEAD -> temp) Merge commit '64046c3' into temp | ||
* 5783c4c (HEAD -> temp) Merge commit 'd216f82' into temp | ||
|\ | ||
* | 1d3fb48 (feature) B | ||
| | * d706821 (master) D | ||
* | 9232f06 (master) D | ||
| | * e926f9d (feature) C | ||
| |/ | ||
| * 64046c3 C | ||
| * d216f82 B | ||
|/ | ||
* 8291506 A | ||
* 24dfa35 A | ||
``` | ||
3. Create another commit from `6cb4aca` with `1d3fb48` as the only parent with [POST /repos/:owner/:repo/git/commits](https://developer.github.com/v3/git/commits/#create-a-commit) and update `temp`'s reference to point to this new commit with [PATCH /repos/:owner/:repo/git/refs/:ref](https://developer.github.com/v3/git/refs/#update-a-reference). | ||
3. Create another commit from `5783c4c` with `9232f06` as the only parent with [POST /repos/:owner/:repo/git/commits](https://developer.github.com/v3/git/commits/#create-a-commit) and update `temp`'s reference to point to this new commit with [PATCH /repos/:owner/:repo/git/refs/:ref](https://developer.github.com/v3/git/refs/#update-a-reference). | ||
<!-- | ||
git cat-file -p 6cb4aca | ||
git commit-tree db5a9e1 -p 1d3fb48 -m C | ||
git update-ref HEAD 5b0786f | ||
git commit-tree db5a9e1 -p 1d3fb48 -m B | ||
git update-ref HEAD 1616ba2 | ||
--> | ||
``` | ||
* 5b0786f (HEAD -> temp) C | ||
* 1d3fb48 (feature) B | ||
| * d706821 (master) D | ||
| * 64046c3 C | ||
* 1616ba2 (HEAD -> temp) B | ||
* 9232f06 (master) D | ||
| * e926f9d (feature) C | ||
| * d216f82 B | ||
|/ | ||
* 8291506 A | ||
* 24dfa35 A | ||
``` | ||
4. Repeat steps 2. and 3. to cherry-pick `d706821` on `temp`. | ||
4. Repeat steps 2. and 3. to cherry-pick `e926f9d` on `temp`. | ||
``` | ||
* ce81b2b (HEAD -> temp) D | ||
* 5b0786f C | ||
* 1d3fb48 (feature) B | ||
| * d706821 (master) D | ||
| * 64046c3 C | ||
* d82c247 (HEAD -> temp) C | ||
* 1616ba2 B | ||
* 9232f06 (master) D | ||
| * e926f9d (feature) C | ||
| * d216f82 B | ||
|/ | ||
* 8291506 A | ||
* 24dfa35 A | ||
``` | ||
5. Set `feature`'s reference to the same one than `temp` with [PATCH /repos/:owner/:repo/git/refs/:ref](https://developer.github.com/v3/git/refs/#update-a-reference), making sure it's a fast-forward update. | ||
5. Set `master`'s reference to the same one than `temp` with [PATCH /repos/:owner/:repo/git/refs/:ref](https://developer.github.com/v3/git/refs/#update-a-reference), making sure it's a fast-forward update. | ||
<!-- | ||
@@ -143,9 +160,9 @@ git checkout feature | ||
``` | ||
* ce81b2b (HEAD -> feature, temp) D | ||
* 5b0786f C | ||
* 1d3fb48 B | ||
| * d706821 (master) D | ||
| * 64046c3 C | ||
* d82c247 (HEAD -> master, temp) C | ||
* 1616ba2 B | ||
* 9232f06 D | ||
| * e926f9d (feature) C | ||
| * d216f82 B | ||
|/ | ||
* 8291506 A | ||
* 24dfa35 A | ||
``` | ||
@@ -157,9 +174,9 @@ 6. Delete the `temp` branch with [DELETE /repos/:owner/:repo/git/refs/:ref](https://developer.github.com/v3/git/refs/#delete-a-reference) and we're done! | ||
``` | ||
* ce81b2b (HEAD -> feature) D | ||
* 5b0786f C | ||
* 1d3fb48 B | ||
| * d706821 (master) D | ||
| * 64046c3 C | ||
* d82c247 (HEAD -> master) C | ||
* 1616ba2 B | ||
* 9232f06 D | ||
| * e926f9d (feature) C | ||
| * d216f82 B | ||
|/ | ||
* 8291506 A | ||
* 24dfa35 A | ||
``` | ||
@@ -166,0 +183,0 @@ |
17197
183