mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix up merge conflict handling
This commit is contained in:
parent
2f6ac42efe
commit
d5619d2b9d
@ -1768,7 +1768,7 @@ RED.diff = (function() {
|
||||
// }
|
||||
|
||||
var actualLineNumber = hunk.diffStart + lineNumber;
|
||||
var isMergeHeader = isConflict && /^..(<<<<<<<|=======$|>>>>>>>)/.test(lineText);
|
||||
var isMergeHeader = isConflict && /^\+\+(<<<<<<<|=======$|>>>>>>>)/.test(lineText);
|
||||
var diffRow = $('<tr>').appendTo(codeBody);
|
||||
var localLineNo = $('<td class="lineno">').appendTo(diffRow);
|
||||
var remoteLineNo;
|
||||
@ -1827,7 +1827,7 @@ RED.diff = (function() {
|
||||
$('<span>').text(lineText.substring(prefixEnd)).appendTo(line);
|
||||
} else {
|
||||
diffRow.addClass("mergeHeader");
|
||||
var isSeparator = /^..(=======$)/.test(lineText);
|
||||
var isSeparator = /^\+\+=======$/.test(lineText);
|
||||
if (!isSeparator) {
|
||||
var isOurs = /^..<<<<<<</.test(lineText);
|
||||
if (isOurs) {
|
||||
@ -2047,7 +2047,7 @@ RED.diff = (function() {
|
||||
} else {
|
||||
lines = diff.split("\n");
|
||||
}
|
||||
var diffHeader = /^diff --git a\/(.*) b\/(.*)$/;
|
||||
var diffHeader = /^diff (?:(?:--git a\/(.*) b\/(.*))|(?:--cc (.*)))$/;
|
||||
var fileHeader = /^\+\+\+ b\/(.*)\t?/;
|
||||
var binaryFile = /^Binary files /;
|
||||
var hunkHeader = /^@@ -((\d+)(,(\d+))?) \+((\d+)(,(\d+))?) @@ ?(.*)$/;
|
||||
@ -2066,7 +2066,7 @@ RED.diff = (function() {
|
||||
}
|
||||
currentHunk = null;
|
||||
currentFile = {
|
||||
file: diffLine[1],
|
||||
file: diffLine[1]||diffLine[3],
|
||||
hunks: []
|
||||
}
|
||||
} else if (binaryFile.test(line)) {
|
||||
|
@ -51,10 +51,6 @@ RED.sidebar.versionControl = (function() {
|
||||
// done(error,null);
|
||||
},
|
||||
200: function(data) {
|
||||
if (mergeConflictNotification) {
|
||||
mergeConflictNotification.close();
|
||||
mergeConflictNotification = null;
|
||||
}
|
||||
var title;
|
||||
if (state === 'unstaged') {
|
||||
title = 'Unstaged changes : '+entry.file
|
||||
@ -102,9 +98,7 @@ RED.sidebar.versionControl = (function() {
|
||||
},{resolutions:resolution.resolutions[entry.file]});
|
||||
}
|
||||
}
|
||||
options.oncancel = showMergeConflictNotification;
|
||||
RED.diff.showUnifiedDiff(options);
|
||||
// console.log(data.diff);
|
||||
},
|
||||
400: {
|
||||
'unexpected_error': function(error) {
|
||||
@ -377,6 +371,16 @@ RED.sidebar.versionControl = (function() {
|
||||
scrollOnAdd: false,
|
||||
addItem: function(row,index,entry) {
|
||||
createChangeEntry(row,entry,entry.treeStatus,'unmerged');
|
||||
if (entry === emptyMergedItem) {
|
||||
var toolbar = $('<div style="text-align: center"></div>').appendTo(row);
|
||||
$('<button class="editor-button editor-button-small">commit</button>')
|
||||
.appendTo(toolbar)
|
||||
.click(function(evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
showCommitBox();
|
||||
});
|
||||
}
|
||||
},
|
||||
sort: function(A,B) {
|
||||
if (A.treeStatus === '?' && B.treeStatus !== '?') {
|
||||
@ -395,28 +399,32 @@ RED.sidebar.versionControl = (function() {
|
||||
header = $('<div class="sidebar-version-control-change-header">Changes to commit</div>').appendTo(stagedContent);
|
||||
|
||||
bg = $('<div style="float: right"></div>').appendTo(header);
|
||||
var showCommitBox = function() {
|
||||
commitMessage.val("");
|
||||
submitCommitButton.attr("disabled",true);
|
||||
unstagedContent.css("height","30px");
|
||||
if (unmergedContent.is(":visible")) {
|
||||
unmergedContent.css("height","30px");
|
||||
stagedContent.css("height","calc(100% - 60px - 175px)");
|
||||
} else {
|
||||
stagedContent.css("height","calc(100% - 30px - 175px)");
|
||||
}
|
||||
commitBox.show();
|
||||
setTimeout(function() {
|
||||
commitBox.css("height","175px");
|
||||
},10);
|
||||
stageAllButton.attr("disabled",true);
|
||||
unstageAllButton.attr("disabled",true);
|
||||
commitButton.attr("disabled",true);
|
||||
abortMergeButton.attr("disabled",true);
|
||||
commitMessage.focus();
|
||||
}
|
||||
commitButton = $('<button class="editor-button editor-button-small" style="margin-right: 5px;">commit</button>')
|
||||
.appendTo(bg)
|
||||
.click(function(evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
commitMessage.val("");
|
||||
submitCommitButton.attr("disabled",true);
|
||||
unstagedContent.css("height","30px");
|
||||
if (unmergedContent.is(":visible")) {
|
||||
unmergedContent.css("height","30px");
|
||||
stagedContent.css("height","calc(100% - 60px - 175px)");
|
||||
} else {
|
||||
stagedContent.css("height","calc(100% - 30px - 175px)");
|
||||
}
|
||||
commitBox.show();
|
||||
setTimeout(function() {
|
||||
commitBox.css("height","175px");
|
||||
},10);
|
||||
stageAllButton.attr("disabled",true);
|
||||
unstageAllButton.attr("disabled",true);
|
||||
commitButton.attr("disabled",true);
|
||||
commitMessage.focus();
|
||||
showCommitBox();
|
||||
});
|
||||
unstageAllButton = $('<button class="editor-button editor-button-small"><i class="fa fa-minus"></i> all</button>')
|
||||
.appendTo(bg)
|
||||
@ -467,6 +475,8 @@ RED.sidebar.versionControl = (function() {
|
||||
stageAllButton.attr("disabled",false);
|
||||
unstageAllButton.attr("disabled",false);
|
||||
commitButton.attr("disabled",false);
|
||||
abortMergeButton.attr("disabled",false);
|
||||
|
||||
})
|
||||
var submitCommitButton = $('<button class="editor-button">Commit</button>')
|
||||
.appendTo(commitToolbar)
|
||||
@ -1045,16 +1055,6 @@ RED.sidebar.versionControl = (function() {
|
||||
// }
|
||||
// }
|
||||
|
||||
function showMergeConflictNotification() {
|
||||
if (isMerging) {
|
||||
mergeConflictNotification = RED.notify("NLS: Automatic merging of remote changes failed. Fix the unmerged conflicts then commit the results."+
|
||||
'<p><a href="#" onclick="RED.sidebar.versionControl.showLocalChanges(); return false;">'+'Show merge conflicts'+'</a></p>',"error",true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function refreshFiles(result) {
|
||||
var files = result.files;
|
||||
if (bulkChangeSpinner) {
|
||||
@ -1064,7 +1064,22 @@ RED.sidebar.versionControl = (function() {
|
||||
isMerging = !!result.merging;
|
||||
if (isMerging) {
|
||||
if (!mergeConflictNotification) {
|
||||
showMergeConflictNotification();
|
||||
var text = "<p>Automatic merging of changes failed.</p><p>Fix the unmerged conflicts then commit the results.</p>";
|
||||
var options = {
|
||||
type: 'error',
|
||||
fixed: true,
|
||||
id: 'merge-conflict',
|
||||
buttons: [
|
||||
{
|
||||
text: "Show merge conflicts",
|
||||
click: function() {
|
||||
mergeConflictNotification.hideNotification();
|
||||
RED.sidebar.versionControl.showLocalChanges();
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
mergeConflictNotification = RED.notify(text,options);
|
||||
}
|
||||
sidebarContent.addClass("sidebar-version-control-merging");
|
||||
unmergedContent.show();
|
||||
|
@ -501,9 +501,9 @@
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
display: none;
|
||||
}
|
||||
button {
|
||||
width: 24px;
|
||||
button {
|
||||
width: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
|
@ -523,11 +523,11 @@ Project.prototype.pull = function (user,remoteBranchName,setRemote) {
|
||||
if (setRemote) {
|
||||
return gitTools.setUpstream(this.path, remoteBranchName).then(function() {
|
||||
self.currentRemote = self.parseRemoteBranch(remoteBranchName).remote;
|
||||
return gitTools.pull(self.path, null, null, authCache.get(self.name,self.remotes[self.currentRemote].fetch,username));
|
||||
return gitTools.pull(self.path, null, null, authCache.get(self.name,self.remotes[self.currentRemote].fetch,username),getGitUser(user));
|
||||
})
|
||||
} else {
|
||||
var remote = this.parseRemoteBranch(remoteBranchName);
|
||||
return gitTools.pull(this.path, remote.remote, remote.branch, authCache.get(this.name,this.remotes[remote.remote||self.currentRemote].fetch,username));
|
||||
return gitTools.pull(this.path, remote.remote, remote.branch, authCache.get(this.name,this.remotes[remote.remote||self.currentRemote].fetch,username),getGitUser(user));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -428,12 +428,20 @@ module.exports = {
|
||||
var args = ["branch","--set-upstream-to",remoteBranch];
|
||||
return runGitCommand(args,cwd);
|
||||
},
|
||||
pull: function(cwd,remote,branch,auth) {
|
||||
pull: function(cwd,remote,branch,auth,gitUser) {
|
||||
var args = ["pull"];
|
||||
if (remote && branch) {
|
||||
args.push(remote);
|
||||
args.push(branch);
|
||||
}
|
||||
if (gitUser && gitUser['name'] && gitUser['email']) {
|
||||
args.unshift('user.name="'+gitUser['name']+'"');
|
||||
args.unshift('-c');
|
||||
args.unshift('user.email="'+gitUser['email']+'"');
|
||||
args.unshift('-c');
|
||||
}
|
||||
//TODO: only do this if asked for
|
||||
args.push("--allow-unrelated-histories");
|
||||
var promise;
|
||||
if (auth) {
|
||||
if ( auth.key_path ) {
|
||||
@ -556,7 +564,7 @@ module.exports = {
|
||||
return runGitCommand(args,cwd,env);
|
||||
},
|
||||
getFileDiff(cwd,file,type) {
|
||||
var args = ["diff"];
|
||||
var args = ["diff","-w"];
|
||||
if (type === "tree") {
|
||||
// nothing else to do
|
||||
} else if (type === "index") {
|
||||
|
Loading…
Reference in New Issue
Block a user