fix(backend-github): don't create new commits on empty diff when rebasing (#3411)
This commit is contained in:
parent
c2e7a24dc2
commit
70de9f6b4b
@ -989,18 +989,24 @@ export default class API {
|
|||||||
const result = await this.getDifferences(commit.parents[0].sha, commit.sha);
|
const result = await this.getDifferences(commit.parents[0].sha, commit.sha);
|
||||||
const files = getTreeFiles(result.files as GitHubCompareFiles);
|
const files = getTreeFiles(result.files as GitHubCompareFiles);
|
||||||
|
|
||||||
// create a tree with baseCommit as the base with the diff applied
|
// only update the tree if changes were detected
|
||||||
const tree = await this.updateTree(baseCommit.sha, files);
|
if (files.length > 0) {
|
||||||
const { message, author, committer } = commit.commit;
|
// create a tree with baseCommit as the base with the diff applied
|
||||||
|
const tree = await this.updateTree(baseCommit.sha, files);
|
||||||
|
const { message, author, committer } = commit.commit;
|
||||||
|
|
||||||
// create a new commit from the updated tree
|
// create a new commit from the updated tree
|
||||||
return (this.createCommit(
|
const newCommit = await this.createCommit(
|
||||||
message,
|
message,
|
||||||
tree.sha,
|
tree.sha,
|
||||||
[baseCommit.sha],
|
[baseCommit.sha],
|
||||||
author,
|
author,
|
||||||
committer,
|
committer,
|
||||||
) as unknown) as GitHubCompareCommit;
|
);
|
||||||
|
return (newCommit as unknown) as GitHubCompareCommit;
|
||||||
|
} else {
|
||||||
|
return commit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user