var inputFile = __dirname + '/' + argv.input;
var configFile = __dirname + '/' + argv.config;
var fromIssueId = Number(argv.from||0);
-var gitlabAPIURLBase = argv.gitlaburl + '/api/v3';
+var gitlabAPIURLBase = argv.gitlaburl + '/api/v4';
var gitlabProjectName = argv.project;
var gitlabAdminPrivateToken = argv.token;
var gitlabSudo = argv.sudo;
var gitLab = {};
var promise = getConfig()
.then(readMantisIssues)
+ .then((JSON.stringify(gitLab.mantisIssues)))
.then(getGitLabProject)
.then(getGitLabProjectMembers)
.then(mapGitLabUserIds)
var rows = [];
var dfd = Q.defer();
- csv().from(data, {delimiter: ',', escape: '"', columns: true})
+ csv().from(data, {delimiter: '\t', quote: '~', escape: '~', columns: true})
.on('record', function(row, index) { rows.push(row) })
.on('end', function(error, data) {
dfd.resolve(rows);
return getIssue(gitLab.project.id, issueId)
.then(function(gitLabIssue) {
if (gitLabIssue) {
- return updateIssue(gitLab.project.id, gitLabIssue.id, _.extend({
+ return updateIssue(gitLab.project.id, issueId, _.extend({
state_event: isClosed(mantisIssue) ? 'close' : 'reopen'
}, data))
.then(function() {
}
function insertSkippedIssues(issueId) {
- if (gitLab.gitlabIssues[issueId]) {
+ if (issueId < 1 || gitLab.gitlabIssues[issueId]) {
return Q();
}
console.warn(("Skipping Missing Mantis Issue (<= #" + issueId + ") ...").yellow);
var data = {
- title: "Skipped Mantis Issue",
+ title: "--Platzhalter--",
+ description: "Fehlende Bugnummer in Mantis. Wird hier ausgelassen, damit die Bugnummern in Mantis mit denen in Gitlab uebereinstimmen.",
sudo: gitlabSudo,
private_token: gitlabAdminPrivateToken
};
log_progress("Fetching Project Issues from GitLab [" + (from + 1) + "-" + (from + per_page) + "]...");
var url = gitlabAPIURLBase + '/projects/' + gitLab.project.id + "/issues";
var data = {
- page: page,
- per_page: per_page,
- order_by: 'id',
+ // FIXME: schnalke
+ //page: page,
+ //per_page: per_page,
+ //order_by: 'id',
private_token: gitlabAdminPrivateToken, sudo: gitlabSudo };
return rest.get(url, {data: data}).then(function(issues) {
description += "\n\n" + value.split("$$$$").join("\n\n")
}
+ description = description.replace(/\\n/g, "\n");
+
+ description = description.replace(/\n *----/g, "\n>>>");
+
+ //description = description.replace(/schnalke/g, "@MSchnalke");
+
+ Object.keys(config.users).forEach(function(muser) {
+ if (muser != "") {
+ var gluser = config.users[muser].gl_username;
+ var re = new RegExp(muser, "g");
+ description = description.replace(re, "@" + gluser);
+ }
+ });
+
return description;
}
function log_progress(message) {
console.log(message.grey);
-}
\ No newline at end of file
+}