From 3be074051068459c940f10e3bd7e56754c8b1bd3 Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 4 Sep 2015 17:32:20 +0200 Subject: [PATCH] update labels on existing issues in case the issue has been created prior to the label specification --- bin/generate-issues | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/bin/generate-issues b/bin/generate-issues index 8b96043..5cd7e98 100755 --- a/bin/generate-issues +++ b/bin/generate-issues @@ -177,6 +177,13 @@ def make_task_issue(github, repo, task, options) sleep THROTTLE_SECONDS else puts "Found Issue #{repo}##{issue.number}: #{issue.title}" + existing_labels = issue.labels.map { |label| label['name']} + missing_labels = options[:labels].reject { |label| existing_labels.include? label } + if not missing_labels.empty? + puts "Updating milestone, labels on #{repo}##{issue.number}" + github.update_issue(repo, issue.number, options) + sleep THROTTLE_SECONDS + end end end @@ -198,6 +205,13 @@ def make_deliverable_issue(github, repo, deliverable, options) sleep THROTTLE_SECONDS else puts "Found Issue #{repo}##{issue.number}: #{issue.title}" + existing_labels = issue.labels.map { |label| label['name']} + missing_labels = options[:labels].reject { |label| existing_labels.include? label } + if issue.milestone.nil? or not missing_labels.empty? + puts "Updating milestone, labels on #{repo}##{issue.number}" + github.update_issue(repo, issue.number, options) + sleep THROTTLE_SECONDS + end end end @@ -253,7 +267,7 @@ def populate_workpackage(github, repo, workpackage) :labels => [ 'task', workpackage['label'], - ].join(',') + ] }) end workpackage['deliverables'].each do |deliverable| @@ -263,7 +277,7 @@ def populate_workpackage(github, repo, workpackage) :labels => [ 'deliverable', workpackage['label'], - ].join(',') + ] }) end end @@ -340,7 +354,7 @@ def load_pdata(proposal_dir) tasks[name][key] = value else - puts " Ignored: #{args}" + # puts " Ignored: #{args}" end end