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

Method rebaseSingleCommit

packages/decap-cms-backend-github/src/API.ts:1083–1110  ·  view source on GitHub ↗
(baseCommit: GitHubCompareCommit, commit: GitHubCompareCommit)

Source from the content-addressed store, hash-verified

1081 }
1082
1083 async rebaseSingleCommit(baseCommit: GitHubCompareCommit, commit: GitHubCompareCommit) {
1084 // first get the diff between the commits
1085 const result = await this.getDifferences(commit.parents[0].sha, commit.sha);
1086 const files = getTreeFiles(result.files as GitHubCompareFiles);
1087
1088 // only update the tree if changes were detected
1089 if (files.length > 0) {
1090 // create a tree with baseCommit as the base with the diff applied
1091 const tree = await this.updateTree(baseCommit.sha, files);
1092 const { message, author, committer } = commit.commit;
1093
1094 // create a new commit from the updated tree
1095 const newCommit = await this.createCommit(
1096 message,
1097 tree.sha,
1098 [baseCommit.sha],
1099 author
1100 ? { name: author.name || '', email: author.email || '', date: author.date }
1101 : undefined,
1102 committer
1103 ? { name: committer.name || '', email: committer.email || '', date: committer.date }
1104 : undefined,
1105 );
1106 return newCommit as unknown as GitHubCompareCommit;
1107 } else {
1108 return commit;
1109 }
1110 }
1111
1112 /**
1113 * Rebase an array of commits one-by-one, starting from a given base SHA

Callers 2

rebaseCommitsMethod · 0.95
API.spec.jsFile · 0.80

Calls 4

getDifferencesMethod · 0.95
updateTreeMethod · 0.95
createCommitMethod · 0.95
getTreeFilesFunction · 0.85

Tested by

no test coverage detected