lib/learn_submit/submission.rb in learn-submit-1.1.6 vs lib/learn_submit/submission.rb in learn-submit-1.1.7

- old
+ new

@@ -48,12 +48,14 @@ # Just to give GitHub a second to register the repo changes sleep(1) end def submit!(retries=3) - puts 'Submitting lesson...' - File.write(file_path, 'Opening a Pull Request...') + if retries >= 2 + puts 'Submitting lesson...' + File.write(file_path, 'Opening a Pull Request...') + end repo_name = git.repo_name branch_name = git.branch_name sleep(1) begin @@ -79,18 +81,23 @@ when 404 puts 'Sorry, it seems like there was a problem connecting with Learn. Please try again.' File.write(file_path, 'ERROR: Error connecting to learn.') exit 1 else - puts pr_response.message - - if pr_response.message.match(/looks the same/) - File.write(file_path, 'ERROR: Nothing to submit') + if retries > 0 + sleep(2) + submit!(0) else - File.write(file_path, 'Done.') - end + puts pr_response.message - exit 1 + if pr_response.message.match(/looks the same/) + File.write(file_path, 'ERROR: Nothing to submit') + else + File.write(file_path, 'Done.') + end + + exit 1 + end end end end end