damus-github-export

Damus issue data exported from github
git clone git://jb55.com/damus-github-export
Log | Files | Refs | README | LICENSE

commit 70adbb18ba47df6fd0d666590169e011faed587b
parent cd5e9378ad30e02865ca7d25a8594f69c2dd9914
Author: Olivier Jacques <ojacques2@gmail.com>
Date:   Wed, 19 Jul 2017 14:27:07 +0200

Add support of closed issues with 2 steps process

Diffstat:
Mindex.js | 34++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/index.js b/index.js @@ -71,6 +71,8 @@ program var labelsIndex = cols.indexOf('labels'); var milestoneIndex = cols.indexOf('milestone'); var assigneeIndex = cols.indexOf('assignee'); + var stateIndex = cols.indexOf('state'); + var issueNumber = 0; if (titleIndex === -1) { console.error('Title required by GitHub, but not found in CSV.'); @@ -102,12 +104,32 @@ program if (assigneeIndex > -1 && row[assigneeIndex] !== '') { sendObj.assignee = row[assigneeIndex]; } - - limiter.submit(github.issues.create,sendObj, function(err, res) - { - // debugging: console.log(JSON.stringify(res)); - if (limiter.nbQueued() === 0) { - process.exit(0); + + limiter.submit(github.issues.create,sendObj, function(err, res) { + // Debugging console.log(JSON.stringify(res)); + if (err) {console.error('ERROR', err)} else { + console.log("===> Created issue #" + res.number) + // if we have a state column and state=closed, close the issue + if (stateIndex > -1 && row[stateIndex] == 'closed') { + console.log("===> Closing issue #" + res.number); + var updateIssue = { + user: values.userOrOrganization, + repo: values.repo, + number: res.number, + state: row[stateIndex] + }; + limiter.submit(github.issues.edit, updateIssue, function(err,res) { + // Debugging console.log(JSON.stringify(res)); + if (err) {console.error('ERROR', err)}; + if (limiter.nbQueued() === 0 && limiter.nbRunning() === 0) { + process.exit(0); + } + }); + } else { + if (limiter.nbQueued() === 0 && limiter.nbRunning() === 0) { + process.exit(0); + } + } } }); });