lib/whatsup_github/pulls.rb in whatsup_github-0.4.0 vs lib/whatsup_github/pulls.rb in whatsup_github-0.4.1

- old
+ new

@@ -45,11 +45,23 @@ def base_branch configuration.base_branch end + # Authorize with a GitHub token from $WHATSUP_GITHUB_ACCESS_TOKEN if available + # Otherwise, use credentials from ~/.netrc + # Otherwise, continue as a Guest def client - Octokit::Client.new(netrc: true) + return @client if @client + + @client = + if ENV['WHATSUP_GITHUB_ACCESS_TOKEN'] + Octokit::Client.new(access_token: ENV['WHATSUP_GITHUB_ACCESS_TOKEN']) + elsif File.exist? "#{ENV['HOME']}/.netrc" + Octokit::Client.new(netrc: true) + else + Octokit::Client.new + end end def search_issues(label) auto_paginate query = "repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch}"