lib/unwrappr/cli.rb in unwrappr-0.5.0 vs lib/unwrappr/cli.rb in unwrappr-0.6.0

- old
+ new

@@ -15,19 +15,26 @@ to use the current branch, or repository's default branch (typically 'origin/main') on clone. DESCRIPTION attribute_name: :base_branch) + option ['-f', '--lock-file'], + 'LOCK_FILE1 [-f LOCK_FILE2] [-f LOCK_FILE3] [-f ...]', + 'The Gemfile.lock files to annotate. Useful when working with multiple lock files.', + multivalued: true, + default: ['Gemfile.lock'], + attribute_name: :lock_files + option ['-v', '--version'], :flag, 'Show version' do puts "unwrappr v#{Unwrappr::VERSION}" exit(0) end subcommand 'all', 'run bundle update, push to github, '\ 'create a pr and annotate changes' do def execute - Unwrappr.run_unwapper_in_pwd(base_branch: base_branch) + Unwrappr.run_unwapper_in_pwd(base_branch: base_branch, lock_files: lock_files) end end subcommand 'annotate-pull-request', 'Annotate Gemfile.lock changes in a Github pull request' do @@ -40,11 +47,12 @@ required: true def execute LockFileAnnotator.annotate_github_pull_request( repo: repo, - pr_number: pr.to_i + pr_number: pr.to_i, + lock_files: lock_files ) end end subcommand('clone', <<~DESCRIPTION) do @@ -66,26 +74,26 @@ "https://github.com/#{repo}", repo ) end - Dir.chdir(repo) { Unwrappr.run_unwapper_in_pwd(base_branch: base_branch) } + Dir.chdir(repo) { Unwrappr.run_unwapper_in_pwd(base_branch: base_branch, lock_files: lock_files) } end end end end - def self.run_unwapper_in_pwd(base_branch:) - return unless lockfile_present? + def self.run_unwapper_in_pwd(base_branch:, lock_files:) + return unless any_lockfile_present?(lock_files) puts "Doing the unwrappr thing in #{Dir.pwd}" GitCommandRunner.create_branch!(base_branch: base_branch) BundlerCommandRunner.bundle_update! GitCommandRunner.commit_and_push_changes! - GitHub::Client.make_pull_request! + GitHub::Client.make_pull_request!(lock_files) end - def self.lockfile_present? - GitCommandRunner.file_exist?('Gemfile.lock') + def self.any_lockfile_present?(lock_files) + lock_files.any? { |lock_file| GitCommandRunner.file_exist?(lock_file) } end end