lib/learn_submit/submission/git_interactor.rb in learn-submit-1.0.8 vs lib/learn_submit/submission/git_interactor.rb in learn-submit-1.0.9

- old
+ new

@@ -3,11 +3,10 @@ class GitInteractor attr_reader :username, :git, :message attr_accessor :remote_name, :old_remote_name, :old_url LEARN_ORG_NAMES = [ - 'learn-co', 'learn-co-curriculum', 'learn-co-students' ] def initialize(username:, message:) @@ -50,13 +49,20 @@ end end end def check_remote - self.remote_name = if git.remote.url.match(/#{username}/).nil? - fix_remote! + if git.remote.url.match(/#{username}/).nil? && git.remote.url.match(/#{LEARN_ORG_NAMES.join('|').gsub('-','\-')}/).nil? + puts "It doesn't look like you're in a lesson directory." + puts 'Please cd into an appropriate directory and try again.' + + exit else - git.remote.name + self.remote_name = if git.remote.url.match(/#{username}/).nil? + fix_remote! + else + git.remote.name + end end end def fix_remote! self.old_remote_name = git.remote.name