mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-12 20:09:46 +02:00
#3238 Enhancing the merge commit functionality
This commit is contained in:
@@ -148,7 +148,7 @@ export const branch = function (name, order) {
|
||||
}
|
||||
};
|
||||
|
||||
export const merge = function (otherBranch, tag) {
|
||||
export const merge = function (otherBranch, custom_id, override_type, custom_tag) {
|
||||
otherBranch = common.sanitizeText(otherBranch, configApi.getConfig());
|
||||
const currentCommit = commits[branches[curBranch]];
|
||||
const otherCommit = commits[branches[otherBranch]];
|
||||
@@ -207,6 +207,23 @@ export const merge = function (otherBranch, tag) {
|
||||
loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
|
||||
expected: ['branch abc'],
|
||||
};
|
||||
throw error;
|
||||
} else if (custom_id && typeof commits[custom_id] !== 'undefined') {
|
||||
let error = new Error(
|
||||
'Incorrect usage of "merge". Commit with id:' +
|
||||
custom_id +
|
||||
' already exists, use different custom Id'
|
||||
);
|
||||
error.hash = {
|
||||
text: 'merge ' + otherBranch + custom_id + override_type + custom_tag,
|
||||
token: 'merge ' + otherBranch + custom_id + override_type + custom_tag,
|
||||
line: '1',
|
||||
loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
|
||||
expected: [
|
||||
'merge ' + otherBranch + ' ' + custom_id + '_UNIQUE ' + override_type + ' ' + custom_tag,
|
||||
],
|
||||
};
|
||||
|
||||
throw error;
|
||||
}
|
||||
// if (isReachableFrom(currentCommit, otherCommit)) {
|
||||
@@ -219,13 +236,15 @@ export const merge = function (otherBranch, tag) {
|
||||
// } else {
|
||||
// create merge commit
|
||||
const commit = {
|
||||
id: seq + '-' + getId(),
|
||||
id: custom_id ? custom_id : seq + '-' + getId(),
|
||||
message: 'merged branch ' + otherBranch + ' into ' + curBranch,
|
||||
seq: seq++,
|
||||
parents: [head == null ? null : head.id, branches[otherBranch]],
|
||||
branch: curBranch,
|
||||
type: commitType.MERGE,
|
||||
tag: tag ? tag : '',
|
||||
customType: override_type,
|
||||
customId: custom_id ? true : false,
|
||||
tag: custom_tag ? custom_tag : '',
|
||||
};
|
||||
head = commit;
|
||||
commits[commit.id] = commit;
|
||||
|
Reference in New Issue
Block a user