From 936d9bb9b31e00f3eef7f28350537b683c505fa6 Mon Sep 17 00:00:00 2001 From: jgrau Date: Mon, 16 Nov 2015 21:53:51 +0100 Subject: [PATCH 01/10] Clean up whitespace --- lib/git2pdf.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index 804cd1b..15aeae9 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -123,22 +123,22 @@ def pdf(batch) #text_box fields["due"] || "", :at=>[120,20], :width=>60, :overflow=>:shrink_to_fit y_offset = y_offset + 20 end - + fill_color "EEEEEE" - fill_color "D0021B" if issue[:type] == "BUG" - fill_color "1D8FCE" if issue[:type] == "TASK" + fill_color "D0021B" if issue[:type] == "BUG" + fill_color "1D8FCE" if issue[:type] == "TASK" fill_color "FBF937" if issue[:type] == "FEATURE" fill_color "F5B383" if issue[:type] == "AMEND" fill_color "FBF937" if issue[:type] == "ENHANCEMENT" if issue[:type] and issue[:type] != "" - fill{rectangle([0,220], margin-10, 220)} + fill{rectangle([0,220], margin-10, 220)} else - fill{rectangle([0,220], margin-10, 220)} + fill{rectangle([0,220], margin-10, 220)} end - + fill_color(0,0,0,100) - + # if issue[:type] and issue[:type] != "" # y_offset = y_offset - 20 # # Type @@ -159,8 +159,6 @@ def pdf(batch) #text_box fields[:due] || "", :at=>[120,20], :width=>60, :overflow=>:shrink_to_fit #end - - #if col == 1 # row = row + 1 # col = 0 From edba52c62f7f3352060cb282eafac0ac449b3082 Mon Sep 17 00:00:00 2001 From: jgrau Date: Mon, 16 Nov 2015 21:54:08 +0100 Subject: [PATCH 02/10] Silent labels --- lib/git2pdf.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index 15aeae9..b644626 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -14,6 +14,7 @@ def initialize(options={}) @api = options[:api] || 'https://api.github.com' @labels = "&labels=#{options[:labels]}" || '' @from_number = options[:from_number] || nil + @silent_labels = ['ready', 'in progress', 'in test', 'done'] end def execute @@ -41,7 +42,7 @@ def get_issues next end end - labels = val["labels"].collect { |l| l["name"].upcase }.join(', ') + labels = val["labels"].reject { |l| @silent_labels.include?(l["name"]) }.collect { |l| l["name"].upcase }.join(', ') type = "" type = "BUG" if labels =~ /bug/i #not billable type = "FEATURE" if labels =~ /feature/i #billable From 170cc0d0096a6649bd28fa984c536a0e73327e49 Mon Sep 17 00:00:00 2001 From: jgrau Date: Mon, 16 Nov 2015 22:02:30 +0100 Subject: [PATCH 03/10] Rename to quiet_labels --- lib/git2pdf.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index b644626..f55feed 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -14,7 +14,7 @@ def initialize(options={}) @api = options[:api] || 'https://api.github.com' @labels = "&labels=#{options[:labels]}" || '' @from_number = options[:from_number] || nil - @silent_labels = ['ready', 'in progress', 'in test', 'done'] + @quiet_labels = ['ready', 'in progress', 'in test', 'done'] end def execute @@ -42,7 +42,10 @@ def get_issues next end end - labels = val["labels"].reject { |l| @silent_labels.include?(l["name"]) }.collect { |l| l["name"].upcase }.join(', ') + labels = val["labels"].reject { |l| @quiet_labels.include?(l["name"]) } + .collect { |l| l["name"].upcase } + .join(', ') + type = "" type = "BUG" if labels =~ /bug/i #not billable type = "FEATURE" if labels =~ /feature/i #billable From 048435347d3c916ddd5c3c6389599dee2c19bb0e Mon Sep 17 00:00:00 2001 From: jgrau Date: Mon, 16 Nov 2015 22:05:16 +0100 Subject: [PATCH 04/10] Allow quiet labels to be specified in cli --- bin/git2pdf | 3 ++- lib/git2pdf.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/git2pdf b/bin/git2pdf index 81f0557..35344e8 100755 --- a/bin/git2pdf +++ b/bin/git2pdf @@ -12,6 +12,7 @@ class Git2PdfBash < Thor option :organisation, aliases: :o option :labels, aliases: :l option :from_number, aliases: :f + option :quiet_labels, aliases: :q def gen(repositories="") repos = repositories.split(',').collect { |r| r.strip } @@ -31,7 +32,7 @@ class Git2PdfBash < Thor pass = pass.strip.gsub(/\n/,'') end - g = Git2Pdf.new repos: repos, basic_auth: [options[:user],pass], org: options[:organisation], user: options[:user], api: options[:api], labels: options[:labels], from_number: options[:from_number] + g = Git2Pdf.new repos: repos, basic_auth: [options[:user],pass], org: options[:organisation], user: options[:user], api: options[:api], labels: options[:labels], from_number: options[:from_number], quiet_labels: options[:quiet_labels] done = g.execute puts "\n#{done} cards output to issues.pdf" end diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index f55feed..a9f5fdd 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -14,7 +14,7 @@ def initialize(options={}) @api = options[:api] || 'https://api.github.com' @labels = "&labels=#{options[:labels]}" || '' @from_number = options[:from_number] || nil - @quiet_labels = ['ready', 'in progress', 'in test', 'done'] + @quiet_labels = options[:quiet_labels] || [] end def execute From 5b4ac0939492e096e6f2cddf3ee489f0796e56db Mon Sep 17 00:00:00 2001 From: jgrau Date: Wed, 18 Nov 2015 13:29:28 +0100 Subject: [PATCH 05/10] Use userstory as feature tag --- lib/git2pdf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index a9f5fdd..a184a04 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -48,7 +48,7 @@ def get_issues type = "" type = "BUG" if labels =~ /bug/i #not billable - type = "FEATURE" if labels =~ /feature/i #billable + type = "FEATURE" if labels =~ /userstory/i #billable type = "ENHANCEMENT" if labels =~ /enhancement/i #billable type = "AMEND" if labels =~ /amend/i #not billable type = "TASK" if labels =~ /task/i #not billable From cb26fe31f6fce8c413ecf02d9e3dd883aad5848c Mon Sep 17 00:00:00 2001 From: jgrau Date: Wed, 18 Nov 2015 13:34:52 +0100 Subject: [PATCH 06/10] Use task as userstory instead --- lib/git2pdf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index a184a04..acbc4cf 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -48,10 +48,10 @@ def get_issues type = "" type = "BUG" if labels =~ /bug/i #not billable - type = "FEATURE" if labels =~ /userstory/i #billable + type = "FEATURE" if labels =~ /feature/i #billable type = "ENHANCEMENT" if labels =~ /enhancement/i #billable type = "AMEND" if labels =~ /amend/i #not billable - type = "TASK" if labels =~ /task/i #not billable + type = "TASK" if labels =~ /userstory/i #not billable milestone = val["milestone"] ? val["milestone"]["title"] : "" From 39aeff818df0f59b95626d27de710f2d4584e6a3 Mon Sep 17 00:00:00 2001 From: jgrau Date: Wed, 18 Nov 2015 14:00:54 +0100 Subject: [PATCH 07/10] Temp print closed issues --- lib/git2pdf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index acbc4cf..265b99a 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -28,10 +28,10 @@ def get_issues #json = `curl -u#{auth} https://api.github.com/repos/pocketworks/repo/issues?per_page=100 | jq '.[] | {state: .state, milestone: .milestone.title, created_at: .created_at, title: .title, number: .number, labels: [.labels[].name]}'` json = "" if @org - json = open("#{@api}/repos/#{@org}/#{repo}/issues?per_page=200&state=open#{@labels}", :http_basic_authentication => basic_auth).read + json = open("#{@api}/repos/#{@org}/#{repo}/issues?per_page=200&state=closed#{@labels}", :http_basic_authentication => basic_auth).read else # for stuff like bob/stuff - json = open("#{@api}/repos/#{repo}/issues?per_page=200&state=open#{@labels}", :http_basic_authentication => basic_auth).read + json = open("#{@api}/repos/#{repo}/issues?per_page=200&state=closed#{@labels}", :http_basic_authentication => basic_auth).read end hash = JSON.parse(json) From de4412110a61b18402ec1d26af01523b40c2d8b8 Mon Sep 17 00:00:00 2001 From: jgrau Date: Wed, 18 Nov 2015 14:29:55 +0100 Subject: [PATCH 08/10] Back to open --- lib/git2pdf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index 265b99a..acbc4cf 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -28,10 +28,10 @@ def get_issues #json = `curl -u#{auth} https://api.github.com/repos/pocketworks/repo/issues?per_page=100 | jq '.[] | {state: .state, milestone: .milestone.title, created_at: .created_at, title: .title, number: .number, labels: [.labels[].name]}'` json = "" if @org - json = open("#{@api}/repos/#{@org}/#{repo}/issues?per_page=200&state=closed#{@labels}", :http_basic_authentication => basic_auth).read + json = open("#{@api}/repos/#{@org}/#{repo}/issues?per_page=200&state=open#{@labels}", :http_basic_authentication => basic_auth).read else # for stuff like bob/stuff - json = open("#{@api}/repos/#{repo}/issues?per_page=200&state=closed#{@labels}", :http_basic_authentication => basic_auth).read + json = open("#{@api}/repos/#{repo}/issues?per_page=200&state=open#{@labels}", :http_basic_authentication => basic_auth).read end hash = JSON.parse(json) From bfb3190445be372d2c66e1295871eab0f691c81f Mon Sep 17 00:00:00 2001 From: jgrau Date: Mon, 29 Feb 2016 11:14:17 +0100 Subject: [PATCH 09/10] Add filtering by creation date --- bin/git2pdf | 3 ++- lib/git2pdf.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/git2pdf b/bin/git2pdf index 35344e8..be14c82 100755 --- a/bin/git2pdf +++ b/bin/git2pdf @@ -12,6 +12,7 @@ class Git2PdfBash < Thor option :organisation, aliases: :o option :labels, aliases: :l option :from_number, aliases: :f + option :from_date, aliases: :fd option :quiet_labels, aliases: :q def gen(repositories="") @@ -32,7 +33,7 @@ class Git2PdfBash < Thor pass = pass.strip.gsub(/\n/,'') end - g = Git2Pdf.new repos: repos, basic_auth: [options[:user],pass], org: options[:organisation], user: options[:user], api: options[:api], labels: options[:labels], from_number: options[:from_number], quiet_labels: options[:quiet_labels] + g = Git2Pdf.new repos: repos, basic_auth: [options[:user],pass], org: options[:organisation], user: options[:user], api: options[:api], labels: options[:labels], from_number: options[:from_number], from_date: options[:from_date], quiet_labels: options[:quiet_labels] done = g.execute puts "\n#{done} cards output to issues.pdf" end diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index acbc4cf..f6513bc 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -14,6 +14,7 @@ def initialize(options={}) @api = options[:api] || 'https://api.github.com' @labels = "&labels=#{options[:labels]}" || '' @from_number = options[:from_number] || nil + @from_date = options[:from_date] || nil @quiet_labels = options[:quiet_labels] || [] end @@ -42,6 +43,14 @@ def get_issues next end end + if @from_date + from_date = DateTime.parse(@from_date) + issue_creation_date = DateTime.parse(val["created_at"]) + + if from_date > issue_creation_date + next + end + end labels = val["labels"].reject { |l| @quiet_labels.include?(l["name"]) } .collect { |l| l["name"].upcase } .join(', ') From a408563b302d049d79700f7eccdacd52a234e509 Mon Sep 17 00:00:00 2001 From: jgrau Date: Mon, 29 Feb 2016 11:20:21 +0100 Subject: [PATCH 10/10] Change alias --- bin/git2pdf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/git2pdf b/bin/git2pdf index be14c82..07a5c43 100755 --- a/bin/git2pdf +++ b/bin/git2pdf @@ -11,8 +11,8 @@ class Git2PdfBash < Thor option :api, aliases: :a option :organisation, aliases: :o option :labels, aliases: :l - option :from_number, aliases: :f - option :from_date, aliases: :fd + option :from_number, aliases: :n + option :from_date, aliases: :d option :quiet_labels, aliases: :q def gen(repositories="")