Skip to content

Commit

Permalink
Get rid of constants for PR tokens
Browse files Browse the repository at this point in the history
They are not required on a global scope, so remove them from there

Signed-off-by: Manuel Hutter <manuel@vshn.ch>
Signed-off-by: Manuel Hutter <manuel@hutter.io>
  • Loading branch information
mhutter committed Jun 1, 2020
1 parent a77b968 commit bf27fd8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/modulesync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
require 'modulesync/util'
require 'monkey_patches'

GITHUB_TOKEN = ENV.fetch('GITHUB_TOKEN', '')
GITLAB_TOKEN = ENV.fetch('GITLAB_TOKEN', '')

module ModuleSync # rubocop:disable Metrics/ModuleLength
include Constants

Expand Down Expand Up @@ -173,12 +170,15 @@ def self.update(options)
end

def self.create_pr_manager
if !GITHUB_TOKEN.empty?
github_token = ENV.fetch('GITHUB_TOKEN', '')
gitlab_token = ENV.fetch('GITLAB_TOKEN', '')

if !github_token.empty?
require 'modulesync/pr/github'
ModuleSync::PR::GitHub.new(GITHUB_TOKEN, ENV.fetch('GITHUB_BASE_URL', 'https://api.github.com'))
elsif !GITLAB_TOKEN.empty?
ModuleSync::PR::GitHub.new(github_token, ENV.fetch('GITHUB_BASE_URL', 'https://api.github.com'))
elsif !gitlab_token.empty?
require 'modulesync/pr/github'
ModuleSync::PR::GitLab.new(GITLAB_TOKEN, ENV.fetch('GITLAB_BASE_URL', 'https://gitlab.com/api/v4'))
ModuleSync::PR::GitLab.new(gitlab_token, ENV.fetch('GITLAB_BASE_URL', 'https://gitlab.com/api/v4'))
else
$stderr.puts 'Environment variables GITHUB_TOKEN or GITLAB_TOKEN must be set to use --pr!'
raise
Expand Down

0 comments on commit bf27fd8

Please sign in to comment.