Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 61 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,35 @@ if (settings.gitlab.projectID === null) {
if (err) return console.log(err);
// all milestones are created
getAllGHMilestones(function(milestoneDataA, milestoneDataMappedA) {
// for now use globals
milestoneData = milestoneDataA;
milestoneDataMapped = milestoneDataMappedA;

createAllIssuesAndComments(milestoneData, function(err, data) {
console.log('\n\n\n\nFinished creating all issues and Comments\n\n\n\n')
console.log(err, data)
});
});
// create labels
gitlab.projects.labels.all(settings.gitlab.projectID, null, function(glLabels) {
getAllGHLabelNames(function(ghlabelNames) {
async.each(glLabels, function(glLabel, cb) {
if (ghlabelNames.indexOf(glLabel.name) < 0) {
console.log('Creating new Label', glLabel.name);
createLabel(glLabel, function(err, createLabelData) {
console.log(createLabelData);
return cb(err);
});
} else {
return cb(null);
}
}, function(err) {
if (err) return console.log(err);
// all labels are created

// for now use globals
milestoneData = milestoneDataA;
milestoneDataMapped = milestoneDataMappedA;

createAllIssuesAndComments(milestoneData, function(err, data) {
console.log('\n\n\n\nFinished creating all issues and Comments\n\n\n\n')
console.log(err, data)
});
}); //async
}); // getAllGHLabelNames
}); // gitlab list labels
}); // getAllGHMilestones
}); // async
})
}); // gitlab list milestones
Expand Down Expand Up @@ -206,6 +226,26 @@ function getAllGHIssues(callback) {
}); // async whilst
}

function getAllGHLabelNames(callback) {
github.issues.getLabels({
user: settings.github.username,
repo: settings.github.repo,
per_page: 100
}, function(err, labelData) {
if (err){
console.log(err);
console.log('FAIL!');
exit(1);
}
var labelNames = labelData.map(function(item) {
return item.name;
});

return callback(labelNames);
});

}

function hasNext(item) {
if (item === null) {
return true;
Expand Down Expand Up @@ -248,6 +288,9 @@ function createIssueAndComments(item, callback) {
// return callback();
}
}
if (item.labels) {
props.labels = item.labels;
}
console.log('props', props);
github.issues.create(props, function(err, newIssueData) {
if (!err) {
Expand Down Expand Up @@ -324,3 +367,12 @@ function createMilestone(data, cb) {
due_on: data.due_date + 'T00:00:00Z'
}, cb);
}

function createLabel(glLabel, cb) {
github.issues.createLabel({
user: settings.github.username,
repo: settings.github.repo,
name: glLabel.name,
color: glLabel.color.substr(1) // remove leading "#" because gitlab returns it but github wants the color without it
}, cb);
}