feat(git): allow custom merge commit ids

Currently, merge commits can have a git tag, but they cannot have a
custom git commit ID.

This commit allows modifying the default merge commit id.
It also displays all merge commits IDs, which undoes
3ccf027f42
This commit is contained in:
Alois Klink
2022-08-25 23:18:13 +01:00
parent cde3a7cf70
commit b2f5ba3ee8
6 changed files with 89 additions and 9 deletions

View File

@@ -148,8 +148,17 @@ export const branch = function (name, order) {
}
};
export const merge = function (otherBranch, tag) {
/**
* Creates a merge commit.
*
* @param {string} otherBranch - Target branch to merge to.
* @param {string} [tag] - Git tag to use on this merge commit.
* @param {string} [id] - Git commit id.
*/
export const merge = function (otherBranch, tag, id) {
otherBranch = common.sanitizeText(otherBranch, configApi.getConfig());
id = common.sanitizeText(id, configApi.getConfig());
const currentCommit = commits[branches[curBranch]];
const otherCommit = commits[branches[otherBranch]];
if (curBranch === otherBranch) {
@@ -219,7 +228,7 @@ export const merge = function (otherBranch, tag) {
// } else {
// create merge commit
const commit = {
id: seq + '-' + getId(),
id: id || seq + '-' + getId(),
message: 'merged branch ' + otherBranch + ' into ' + curBranch,
seq: seq++,
parents: [head == null ? null : head.id, branches[otherBranch]],