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

Don't raise on missing config file #80

Merged
merged 2 commits into from
May 13, 2016
Merged
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
5 changes: 1 addition & 4 deletions lib/octopolo/commands/issue.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
desc "Create an issue for the current project."
command 'issue' do |c|
config = Octopolo::Config.parse
user_config = Octopolo::UserConfig.parse

c.desc "Use $EDITOR to update PR description before creating"
c.switch [:e, :editor], :default_value => user_config.editor
c.switch [:e, :editor], :default_value => Octopolo.user_config.editor

c.action do |global_options, options, args|
require_relative '../scripts/issue'
Expand Down
7 changes: 2 additions & 5 deletions lib/octopolo/commands/pull_request.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
desc "Create a pull request from the current branch to the application's designated deploy branch."
command 'pull-request' do |c|
config = Octopolo::Config.parse
user_config = Octopolo::UserConfig.parse

c.desc "Branch to create the pull request against"
c.flag [:d, :dest, :destination], :arg_name => "destination_branch", :default_value => config.deploy_branch
c.flag [:d, :dest, :destination], :arg_name => "destination_branch", :default_value => Octopolo.config.deploy_branch

c.desc "Use $EDITOR to update PR description before creating"
c.switch [:e, :editor], :default_value => user_config.editor
c.switch [:e, :editor], :default_value => Octopolo.user_config.editor

c.action do |global_options, options, args|
require_relative '../scripts/pull_request'
Expand Down
5 changes: 2 additions & 3 deletions lib/octopolo/commands/sync_branch.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
config = Octopolo::Config.parse
long_desc "branch - Which branch to merge into yours (default: #{config.deploy_branch})"
long_desc "branch - Which branch to merge into yours (default: #{Octopolo.config.deploy_branch})"

arg :branch
desc "Merge the #{config.deploy_branch} branch into the current working branch"
desc "Merge the #{Octopolo.config.deploy_branch} branch into the current working branch"
command 'sync-branch' do |c|
c.action do |global_options, options, args|
require_relative '../scripts/sync_branch'
Expand Down
9 changes: 5 additions & 4 deletions lib/octopolo/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ def semantic_versioning
# end defaults

def self.parse
new(attributes_from_file)
new(attributes_from_file || {})
end

def self.attributes_from_file
YAML.load_file(octopolo_config_path)
if path = octopolo_config_path
YAML.load_file(path)
end
end

def self.octopolo_config_path
Expand All @@ -104,8 +106,7 @@ def self.octopolo_config_path
if old_dir != Dir.pwd
octopolo_config_path
else
Octopolo::CLI.say "Could not find #{FILE_NAMES.join(' or ')}"
exit
Octopolo::CLI.say "*** WARNING: Could not find #{FILE_NAMES.join(' or ')} ***"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/octopolo/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ module Octopolo

it "gives up if it can't find a config file" do
File.stub(:exists?) { false }
Octopolo::CLI.should_receive(:say).with("Could not find .octopolo.yml or .automation.yml")
lambda { subject.octopolo_config_path }.should raise_error(SystemExit)
Octopolo::CLI.should_receive(:say).with("*** WARNING: Could not find .octopolo.yml or .automation.yml ***")
subject.octopolo_config_path
Dir.chdir project_working_dir
end

Expand Down