lib/whatsup_github/pulls.rb in whatsup_github-0.2.0 vs lib/whatsup_github/pulls.rb in whatsup_github-0.3.0

- old
+ new

@@ -11,13 +11,16 @@ @since = args[:since] end def filtered issues = [] - labels.each do |label| + required_labels.each do |label| issues += search_issues(label).items end + optional_labels.each do |label| + issues += search_issues_with_magic_word(label).items + end issues end private @@ -27,27 +30,44 @@ def configuration Config.instance end - def labels - configuration.labels + def optional_labels + configuration.optional_labels end + def required_labels + configuration.required_labels + end + + def magic_word + configuration.magic_word + end + def base_branch configuration.base_branch end def client Octokit::Client.new(:netrc => true) end def search_issues(label) auto_paginate - client.search_issues("repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch}") + query = "repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch}" + puts "Searching on GitHub by query #{query}" + client.search_issues(query) end + def search_issues_with_magic_word(label) + auto_paginate + query = "repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch} \"#{magic_word}\" in:body" + puts "Searching on GitHub by query #{query}" + client.search_issues(query) + end + def auto_paginate Octokit.auto_paginate = true end end end @@ -55,6 +75,6 @@ if $PROGRAM_NAME == __FILE__ require 'date' two_weeks_ago = (Date.today - 14).to_s pulls = WhatsupGithub::Pulls.new(repo: 'magento/devdocs', since: two_weeks_ago) p pulls.filtered -end \ No newline at end of file +end