1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

merge upstream/master

This commit is contained in:
Hiroyasu Nishiyama 2018-02-08 23:22:00 +09:00
commit 0bba3dd83d
2 changed files with 19 additions and 17 deletions

View File

@ -381,7 +381,7 @@ Project.prototype.getFileDiff = function(file,type) {
} }
Project.prototype.getCommits = function(options) { Project.prototype.getCommits = function(options) {
return gitTools.getCommits(this.path,options).catch(function(err) { return gitTools.getCommits(this.path,options).catch(function(err) {
if (/ambiguous argument/.test(err.message) || /does not have any commits yet/.test(err.message)) { if (/bad default revision/i.test(err.message) || /ambiguous argument/i.test(err.message) || /does not have any commits yet/i.test(err.message)) {
return { return {
count:0, count:0,
commits:[], commits:[],
@ -733,6 +733,7 @@ Project.prototype.toJSON = function () {
function getCredentialsFilename(filename) { function getCredentialsFilename(filename) {
filename = filename || "undefined";
// TODO: DRY - ./index.js // TODO: DRY - ./index.js
var ffDir = fspath.dirname(filename); var ffDir = fspath.dirname(filename);
var ffExt = fspath.extname(filename); var ffExt = fspath.extname(filename);
@ -741,6 +742,7 @@ function getCredentialsFilename(filename) {
} }
function getBackupFilename(filename) { function getBackupFilename(filename) {
// TODO: DRY - ./index.js // TODO: DRY - ./index.js
filename = filename || "undefined";
var ffName = fspath.basename(filename); var ffName = fspath.basename(filename);
var ffDir = fspath.dirname(filename); var ffDir = fspath.dirname(filename);
return fspath.join(ffDir,"."+ffName+".backup"); return fspath.join(ffDir,"."+ffName+".backup");

View File

@ -48,37 +48,37 @@ function runGitCommand(args,cwd,env) {
var err = new Error(stderr); var err = new Error(stderr);
err.stdout = stdout; err.stdout = stdout;
err.stderr = stderr; err.stderr = stderr;
if (/fatal: could not read/.test(stderr)) { if (/fatal: could not read/i.test(stderr)) {
// Username/Password // Username/Password
err.code = "git_auth_failed"; err.code = "git_auth_failed";
} else if(/HTTP Basic: Access denied/.test(stderr)) { } else if(/HTTP Basic: Access denied/i.test(stderr)) {
err.code = "git_auth_failed"; err.code = "git_auth_failed";
} else if(/Permission denied \(publickey\)/.test(stderr)) { } else if(/Permission denied \(publickey\)/i.test(stderr)) {
err.code = "git_auth_failed"; err.code = "git_auth_failed";
} else if(/Host key verification failed/.test(stderr)) { } else if(/Host key verification failed/i.test(stderr)) {
// TODO: handle host key verification errors separately // TODO: handle host key verification errors separately
err.code = "git_auth_failed"; err.code = "git_auth_failed";
} else if(/Connection refused/.test(stderr)) { } else if(/Connection refused/i.test(stderr)) {
err.code = "git_connection_failed"; err.code = "git_connection_failed";
} else if (/commit your changes or stash/.test(stderr)) { } else if (/commit your changes or stash/i.test(stderr)) {
err.code = "git_local_overwrite"; err.code = "git_local_overwrite";
} else if (/CONFLICT/.test(err.stdout)) { } else if (/CONFLICT/.test(err.stdout)) {
err.code = "git_pull_merge_conflict"; err.code = "git_pull_merge_conflict";
} else if (/not fully merged/.test(stderr)) { } else if (/not fully merged/i.test(stderr)) {
err.code = "git_delete_branch_unmerged"; err.code = "git_delete_branch_unmerged";
} else if (/remote .* already exists/.test(stderr)) { } else if (/remote .* already exists/i.test(stderr)) {
err.code = "git_remote_already_exists"; err.code = "git_remote_already_exists";
} else if (/does not appear to be a git repository/.test(stderr)) { } else if (/does not appear to be a git repository/i.test(stderr)) {
err.code = "git_not_a_repository"; err.code = "git_not_a_repository";
} else if (/Repository not found/i.test(stderr)) { } else if (/Repository not found/i.test(stderr)) {
err.code = "git_repository_not_found"; err.code = "git_repository_not_found";
} else if (/repository '.*' does not exist/i.test(stderr)) { } else if (/repository '.*' does not exist/i.test(stderr)) {
err.code = "git_repository_not_found"; err.code = "git_repository_not_found";
} else if (/refusing to merge unrelated histories/.test(stderr)) { } else if (/refusing to merge unrelated histories/i.test(stderr)) {
err.code = "git_pull_unrelated_history" err.code = "git_pull_unrelated_history"
} else if (/Please tell me who you are/.test(stderr)) { } else if (/Please tell me who you are/i.test(stderr)) {
err.code = "git_missing_user"; err.code = "git_missing_user";
} else if (/name consists only of disallowed characters/.test(stderr)) { } else if (/name consists only of disallowed characters/i.test(stderr)) {
err.code = "git_missing_user"; err.code = "git_missing_user";
} }
return reject(err); return reject(err);
@ -172,7 +172,7 @@ function getStatus(localRepo) {
return runGitCommand(['rev-list', 'HEAD', '--count'],localRepo).then(function(count) { return runGitCommand(['rev-list', 'HEAD', '--count'],localRepo).then(function(count) {
result.commits.total = parseInt(count); result.commits.total = parseInt(count);
}).catch(function(err) { }).catch(function(err) {
if (/ambiguous argument/.test(err.message)) { if (/ambiguous argument/i.test(err.message)) {
result.commits.total = 0; result.commits.total = 0;
} else { } else {
throw err; throw err;
@ -204,7 +204,7 @@ function getStatus(localRepo) {
return runGitCommand(["status","--porcelain","-b"],localRepo).then(function(output) { return runGitCommand(["status","--porcelain","-b"],localRepo).then(function(output) {
var lines = output.split("\n"); var lines = output.split("\n");
var unknownDirs = []; var unknownDirs = [];
var branchLineRE = /^## (?:No commits yet on )?(.+?)(?:$|\.\.\.(.+?)(?:$| \[(?:(?:ahead (\d+)(?:,\s*)?)?(?:behind (\d+))?|(gone))\]))/; var branchLineRE = /^## (?:(?:No commits yet on )|(?:Initial commit on))?(.+?)(?:$|\.\.\.(.+?)(?:$| \[(?:(?:ahead (\d+)(?:,\s*)?)?(?:behind (\d+))?|(gone))\]))/;
lines.forEach(function(line) { lines.forEach(function(line) {
if (line==="") { if (line==="") {
return; return;
@ -450,7 +450,7 @@ module.exports = {
var e = new Error("NLS: pull failed - merge conflict"); var e = new Error("NLS: pull failed - merge conflict");
e.code = "git_pull_merge_conflict"; e.code = "git_pull_merge_conflict";
throw e; throw e;
} else if (/Please commit your changes or stash/.test(err.message)) { } else if (/Please commit your changes or stash/i.test(err.message)) {
var e = new Error("NLS: Pull failed - local changes would be overwritten"); var e = new Error("NLS: Pull failed - local changes would be overwritten");
e.code = "git_pull_overwrite"; e.code = "git_pull_overwrite";
throw e; throw e;
@ -613,7 +613,7 @@ module.exports = {
getRemotes: getRemotes, getRemotes: getRemotes,
getRemoteBranch: function(cwd) { getRemoteBranch: function(cwd) {
return runGitCommand(['rev-parse','--abbrev-ref','--symbolic-full-name','@{u}'],cwd).catch(function(err) { return runGitCommand(['rev-parse','--abbrev-ref','--symbolic-full-name','@{u}'],cwd).catch(function(err) {
if (/no upstream configured for branch/.test(err.message)) { if (/no upstream configured for branch/i.test(err.message)) {
return null; return null;
} }
throw err; throw err;