Skip to content

Commit

Permalink
more tweaks to allow env vars as global config
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Yaco-Mink committed Mar 5, 2014
1 parent ca87911 commit 194e6cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/pt/client.rb
Expand Up @@ -11,6 +11,7 @@ def self.get_api_token(email, password)

def initialize(api_number)
PivotalTracker::Client.token = api_number
puts api_number
@project = nil
end

Expand Down
18 changes: 12 additions & 6 deletions lib/pt/ui.rb
Expand Up @@ -556,15 +556,21 @@ def get_local_config_path
def load_local_config
check_local_config_path
config = YAML.load(File.read(get_local_config_path())) rescue {}
if config.empty? and ENV['PIVOTAL_PROJECT_ID'] and ENV['PIVOTAL_PROJECT_NAME']

config = {
:project_id => ENV['PIVOTAL_PROJECT_ID'],
:project_name => ENV['PIVOTAL_PROJECT_NAME']
}
if ENV['PIVOTAL_PROJECT_ID']

config[:project_id] = ENV['PIVOTAL_PROJECT_ID']

project = @client.get_project(config[:project_id])
config[:project_name] = project.name

membership = @client.get_membership(project, @global_config[:email])
config[:user_name], config[:user_id], config[:user_initials] = membership.name, membership.id, membership.initials
save_config(config, get_local_config_path())

elsif config.empty?
end

if config.empty?
message "I can't find info about this project in #{get_local_config_path()}"
projects = PT::ProjectTable.new(@client.get_projects)
project = select("Please select the project for the current directory", projects)
Expand Down

0 comments on commit 194e6cc

Please sign in to comment.