mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Check the global git config to ensure its setup
This commit is contained in:
@@ -369,11 +369,27 @@ module.exports = {
|
||||
init: function(_settings,_runtime) {
|
||||
log = _runtime.log
|
||||
return new Promise(function(resolve,reject) {
|
||||
runGitCommand(["--version"]).then(function(output) {
|
||||
var m = / (\d\S+)/.exec(output);
|
||||
Promise.all([
|
||||
runGitCommand(["--version"]),
|
||||
runGitCommand(["config","--global","user.name"]).catch(err=>""),
|
||||
runGitCommand(["config","--global","user.email"]).catch(err=>"")
|
||||
]).then(function(output) {
|
||||
var m = / (\d\S+)/.exec(output[0]);
|
||||
gitVersion = m[1];
|
||||
resolve(gitVersion);
|
||||
var globalUserName = output[1].trim();
|
||||
var globalUserEmail = output[2].trim();
|
||||
var result = {
|
||||
version: gitVersion
|
||||
};
|
||||
if (globalUserName && globalUserEmail) {
|
||||
result.user = {
|
||||
name: globalUserName,
|
||||
email: globalUserEmail
|
||||
}
|
||||
}
|
||||
resolve(result);
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
resolve(null);
|
||||
});
|
||||
});
|
||||
|
@@ -37,6 +37,8 @@ var projectLogMessages = [];
|
||||
var projectsDir;
|
||||
var activeProject
|
||||
|
||||
var globalGitUser = false;
|
||||
|
||||
function init(_settings, _runtime) {
|
||||
settings = _settings;
|
||||
runtime = _runtime;
|
||||
@@ -89,11 +91,12 @@ function init(_settings, _runtime) {
|
||||
|
||||
if (projectsEnabled) {
|
||||
return sshTools.init(settings,runtime).then(function() {
|
||||
gitTools.init(_settings, _runtime).then(function(gitVersion) {
|
||||
if (!gitVersion) {
|
||||
gitTools.init(_settings, _runtime).then(function(gitConfig) {
|
||||
if (!gitConfig) {
|
||||
projectLogMessages.push(log._("storage.localfilesystem.projects.git-not-found"))
|
||||
projectsEnabled = false;
|
||||
} else {
|
||||
globalGitUser = gitConfig.user;
|
||||
Projects.init(settings,runtime);
|
||||
sshTools.init(settings,runtime);
|
||||
projectsDir = fspath.join(settings.userDir,"projects");
|
||||
@@ -553,7 +556,7 @@ module.exports = {
|
||||
updateRemote: updateRemote,
|
||||
getFlowFilename: getFlowFilename,
|
||||
getCredentialsFilename: getCredentialsFilename,
|
||||
|
||||
getGlobalGitUser: function() { return globalGitUser },
|
||||
getFlows: getFlows,
|
||||
saveFlows: saveFlows,
|
||||
getCredentials: getCredentials,
|
||||
|
Reference in New Issue
Block a user