return getIssue(gitLab.project.id, issueId)
.then(function(gitLabIssue) {
- if (gitLabIssue) {
+ //console.log(data.title + " -- " + issueId);
+ //console.log(data.title + " -- " + issueId + " -- " + gitLab.gitlabIssues[issueId]);
+ if (gitLab.gitlabIssues[issueId]) {
+ // update
+ console.log("updating: " + data.title + " (Issueid: " + issueId + ")");
return updateIssue(gitLab.project.id, gitLabIssue.iid, _.extend({
state_event: isClosed(mantisIssue) ? 'close' : 'reopen'
}, data))
console.log(("#" + gitLabIssue.iid + ": Updated successfully.").green);
});
} else {
- console.log(data.title);
- //return true; // FIXME
+ // insert
+ console.log("inserting: " + data.title + " (Issueid: " + issueId + ")");
return insertSkippedIssues(issueId-1)
.then(function() {
return insertAndCloseIssue(issueId, data, isClosed(mantisIssue));
return Q();
}
- //FIXME console.warn(("Skipping Missing Mantis Issue (<= #" + issueId + ") ...").yellow);
- console.log(("Adding" + issueId + ") ...").blue);
+ //console.warn(("Skipping Missing Mantis Issue (<= #" + issueId + ") ...").yellow);
+ console.log(("Adding placeholder ...").yellow);
var data = {
- title: "--Platzhalter--",
- description: "Fehlende Bugnummer in Mantis. Wird hier ausgelassen, damit die Bugnummern in Mantis mit denen in Gitlab uebereinstimmen.",
+ title: "-- Platzhalter --",
+ description: "Diese Bugnummer war in Mantis einem anderen Projekt zugeordnet. Dieser Platzhalter sorgt dafuer, dass die Bugnummern in Mantis mit denen in Gitlab uebereinstimmen.",
sudo: gitlabSudo,
private_token: gitlabAdminPrivateToken
};
- return insertAndCloseIssue(issueId, data, true, getSkippedIssueData)
+ return insertAndCloseIssue(issueId, data, true)
.then(function() {
return insertSkippedIssues(issueId);
});
-
- function getSkippedIssueData(gitLabIssue) {
- var issueId = gitLabIssue.iid;
- var description;
- if (config.mantisUrl) {
- description = "[Mantis Issue " + issueId + "](" + config.mantisUrl + "/view.php?id=" + issueId + ")";
- } else {
- description = "Mantis Issue " + issueId;
- }
- return {
- title: "Skipped Mantis Issue " + issueId,
- description: "_Skipped " + description + "_"
- };
- }
}
function insertAndCloseIssue(issueId, data, close, custom) {
if (close) {
return closeIssue(issue, custom && custom(issue)).then(
function() {
- console.log((issueId + ': Inserted and closed successfully. #' + issue.iid).green);
+ console.log((issue.iid + ': Inserted and closed successfully. #' + issue.iid).green);
}, function(error) {
- console.warn((issueId + ': Inserted successfully but failed to close. #' + issue.iid).yellow);
+ console.warn((issue.iid + ': Inserted successfully but failed to close. #' + issue.iid).yellow);
});
}
- console.log((issueId + ': Inserted successfully. #' + issue.iid).green);
+ console.log((issue.iid + ': Inserted successfully. #' + issue.iid).green);
}, function(error) {
- console.error((issueId + ': Failed to insert.').red, error);
+ console.error((issue.iid + ': Failed to insert.').red, error);
});
}
//order_by: 'id',
private_token: gitlabAdminPrivateToken, sudo: gitlabSudo };
- return rest.get(url, {data: data})
return rest.get(url, {data: data})
.fail(function(err) {
console.log(err);
attributes.push("Reported By: " + value);
}
+/*
if (value = row["Assigned To"]) {
attributes.push("Assigned To: " + value);
}
+*/
if (value = row.Created) {
attributes.push("Created: " + value);
}
description = description.replace(/\\n/g, "\n");
+ description = description.replace(/\\t/g, " ");
+ description = description.replace(/``/g, '"');
+ description = description.replace(/''/g, '"');
description = description.replace(/\n *----/g, "\n>>>");