Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiet labels #7

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions bin/git2pdf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class Git2PdfBash < Thor
option :api, aliases: :a
option :organisation, aliases: :o
option :labels, aliases: :l
option :from_number, aliases: :f
option :from_number, aliases: :n
option :from_date, aliases: :d
option :quiet_labels, aliases: :q

def gen(repositories="")
repos = repositories.split(',').collect { |r| r.strip }
Expand All @@ -31,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]
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
Expand Down
33 changes: 22 additions & 11 deletions lib/git2pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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

def execute
Expand Down Expand Up @@ -41,13 +43,24 @@ def get_issues
next
end
end
labels = val["labels"].collect { |l| l["name"].upcase }.join(', ')
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(', ')

type = ""
type = "BUG" if labels =~ /bug/i #not 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"] : ""

Expand Down Expand Up @@ -123,22 +136,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
Expand All @@ -159,8 +172,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
Expand Down