Skip to content

Instantly share code, notes, and snippets.

View yardenshoham's full-sized avatar

Yarden Shoham yardenshoham

View GitHub Profile
@yardenshoham
yardenshoham / cherry-pick.ts
Created February 22, 2023 20:54
ChatGPT's suggestion for implementing `cherry-pick` in `isomorphic-git`
import { RepoPath, CommitObject, GitError, MergeOptions, MergeReport } from 'isomorphic-git';
import { getCommit, listCommits, merge } from 'isomorphic-git';
// The cherryPick function takes a repository path and a commit SHA as input, and applies the
// changes made in the specified commit to the current branch. The function first gets the commit
// object for the specified commit, and then finds the parent commit(s) to use as the merge base(s).
// It then sets up the merge options, with ours set to the current HEAD commit and theirs set to the
// specified commit. The fastForwardOnly and noUpdateBranch options are used to ensure that the
// merge only applies changes from the specified commit, and does not change the branch reference
// or allow non-fast-forward merges. The merge function is then called to perform the merge and