MCPcopy Create free account
hub / github.com/decaporg/decap-cms / rebaseCommits

Method rebaseCommits

packages/decap-cms-backend-github/src/API.ts:1115–1138  ·  view source on GitHub ↗

* Rebase an array of commits one-by-one, starting from a given base SHA

(baseCommit: GitHubCompareCommit, commits: GitHubCompareCommits)

Source from the content-addressed store, hash-verified

1113 * Rebase an array of commits one-by-one, starting from a given base SHA
1114 */
1115 async rebaseCommits(baseCommit: GitHubCompareCommit, commits: GitHubCompareCommits) {
1116 /**
1117 * If the parent of the first commit already matches the target base,
1118 * return commits as is.
1119 */
1120 if (commits.length === 0 || commits[0].parents[0].sha === baseCommit.sha) {
1121 const head = last(commits) as GitHubCompareCommit;
1122 return head;
1123 } else {
1124 /**
1125 * Re-create each commit over the new base, applying each to the previous,
1126 * changing only the parent SHA and tree for each, but retaining all other
1127 * info, such as the author/committer data.
1128 */
1129 const newHeadPromise = commits.reduce((lastCommitPromise, commit) => {
1130 return lastCommitPromise.then(newParent => {
1131 const parent = newParent;
1132 const commitToRebase = commit;
1133 return this.rebaseSingleCommit(parent, commitToRebase);
1134 });
1135 }, Promise.resolve(baseCommit));
1136 return newHeadPromise;
1137 }
1138 }
1139
1140 async rebaseBranch(branch: string) {
1141 try {

Callers 1

rebaseBranchMethod · 0.95

Calls 1

rebaseSingleCommitMethod · 0.95

Tested by

no test coverage detected