The version we used to actually import
[mantis2gitlab] / m2gl.js
diff --git a/m2gl.js b/m2gl.js
index c172d0a..2a13ff5 100644 (file)
--- a/m2gl.js
+++ b/m2gl.js
@@ -216,6 +216,7 @@ function importIssue(mantisIssue) {
   var milestoneId = '';
   var labels = getLabels(mantisIssue);
   var author = getUserByMantisUsername(mantisIssue.Reporter);
+  var created = mantisIssue.Created.replace(" ", "T") + "Z";
 
   log_progress("Importing: #" + issueId + " - " + title + " ...");
 
@@ -225,14 +226,13 @@ function importIssue(mantisIssue) {
     assignee_id: assignee && assignee.gl_id,
     milestone_id: milestoneId,
     labels: labels,
+    created_at: created,
     sudo: gitlabSudo,
     private_token: gitlabAdminPrivateToken
   };
 
   return getIssue(gitLab.project.id, issueId)
       .then(function(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 + ")");
@@ -245,10 +245,14 @@ function importIssue(mantisIssue) {
         } else {
           // insert
           console.log("inserting: " + data.title + " (Issueid: " + issueId + ")");
+          data.iid = issueId;
+          return insertAndCloseIssue(issueId, data, isClosed(mantisIssue));
+/*
           return insertSkippedIssues(issueId-1)
               .then(function() {
                 return insertAndCloseIssue(issueId, data, isClosed(mantisIssue));
               });
+*/
         }
       });
 }
@@ -258,7 +262,6 @@ function insertSkippedIssues(issueId) {
     return Q();
   }
 
-  //console.warn(("Skipping Missing Mantis Issue (<= #" + issueId + ") ...").yellow);
   console.log(("Adding placeholder ...").yellow);
 
   var data = {
@@ -317,8 +320,6 @@ function getRemainingGitLabProjectIssues(page, per_page) {
   var data = {
     page: page,
     per_page: per_page,
-    // FIXME: schnalke
-    //order_by: 'id',
     private_token: gitlabAdminPrivateToken, sudo: gitlabSudo };
 
   return rest.get(url, {data: data})
@@ -356,7 +357,7 @@ function getDescription(row) {
     attributes.push("Reported By: " + value);
   }
 
-/*
+/* omit ...
   if (value = row["Assigned To"]) {
     attributes.push("Assigned To: " + value);
   }
@@ -382,15 +383,16 @@ function getDescription(row) {
     description += "\n\n" + value.split("$$$$").join("\n\n")
   }
 
+  if (value = row.Attachments) {
+    description += "\n\n" + value.split("$$$$").join("\n\n")
+  }
+
   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>>>");
 
-  //description = description.replace(/schnalke/g, "@MSchnalke");
-
   Object.keys(config.users).forEach(function(muser) {
     if (muser != "") {
         var gluser = config.users[muser].gl_username;