mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Ensure git username/email are set on project creation
This commit is contained in:
parent
a9ece5772d
commit
64607df929
@ -40,7 +40,19 @@ function getSSHKeyUsername(userObj) {
|
|||||||
}
|
}
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
function getGitUser(user) {
|
||||||
|
var username;
|
||||||
|
if (!user) {
|
||||||
|
username = "_";
|
||||||
|
} else {
|
||||||
|
username = user.username;
|
||||||
|
}
|
||||||
|
var userSettings = settings.getUserSettings(username);
|
||||||
|
if (userSettings && userSettings.git) {
|
||||||
|
return userSettings.git.user;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
function Project(name) {
|
function Project(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.path = fspath.join(projectsDir,name);
|
this.path = fspath.join(projectsDir,name);
|
||||||
@ -153,7 +165,7 @@ Project.prototype.initialise = function(user,data) {
|
|||||||
return when.all(promises).then(function() {
|
return when.all(promises).then(function() {
|
||||||
return gitTools.stageFile(project.path,files);
|
return gitTools.stageFile(project.path,files);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return gitTools.commit(project.path,"Create project files");
|
return gitTools.commit(project.path,"Create project files",getGitUser(user));
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return project.load()
|
return project.load()
|
||||||
})
|
})
|
||||||
@ -358,14 +370,7 @@ Project.prototype.unstageFile = function(file) {
|
|||||||
return gitTools.unstageFile(this.path,file);
|
return gitTools.unstageFile(this.path,file);
|
||||||
}
|
}
|
||||||
Project.prototype.commit = function(user, options) {
|
Project.prototype.commit = function(user, options) {
|
||||||
var username;
|
return gitTools.commit(this.path,options.message,getGitUser(user));
|
||||||
if (!user) {
|
|
||||||
username = "_";
|
|
||||||
} else {
|
|
||||||
username = user.username;
|
|
||||||
}
|
|
||||||
var gitUser = this.git.user[username];
|
|
||||||
return gitTools.commit(this.path,options.message,gitUser);
|
|
||||||
}
|
}
|
||||||
Project.prototype.getFileDiff = function(file,type) {
|
Project.prototype.getFileDiff = function(file,type) {
|
||||||
return gitTools.getFileDiff(this.path,file,type);
|
return gitTools.getFileDiff(this.path,file,type);
|
||||||
@ -807,7 +812,7 @@ function createDefaultProject(user, project) {
|
|||||||
return when.all(promises).then(function() {
|
return when.all(promises).then(function() {
|
||||||
return gitTools.stageFile(projectPath,files);
|
return gitTools.stageFile(projectPath,files);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return gitTools.commit(projectPath,"Create project");
|
return gitTools.commit(projectPath,"Create project",getGitUser(user));
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user