From ad1d0e3e598deb093d9bd3354fddcd85e24b9431 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Wed, 21 Jul 2021 17:50:34 +1000 Subject: [PATCH 1/5] Fix typo --- lib/unwrappr/cli.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/unwrappr/cli.rb b/lib/unwrappr/cli.rb index 23b911f..35312cd 100644 --- a/lib/unwrappr/cli.rb +++ b/lib/unwrappr/cli.rb @@ -32,7 +32,7 @@ class CLI < Clamp::Command 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, lock_files: lock_files) + Unwrappr.run_unwrappr_in_pwd(base_branch: base_branch, lock_files: lock_files) end end @@ -76,13 +76,13 @@ def execute ) end - Dir.chdir(repo) { Unwrappr.run_unwapper_in_pwd(base_branch: base_branch, lock_files: lock_files) } + Dir.chdir(repo) { Unwrappr.run_unwrappr_in_pwd(base_branch: base_branch, lock_files: lock_files) } end end end end - def self.run_unwapper_in_pwd(base_branch:, lock_files:) + def self.run_unwrappr_in_pwd(base_branch:, lock_files:) return unless any_lockfile_present?(lock_files) puts "Doing the unwrappr thing in #{Dir.pwd}" From a21f0527fcd999899d8da0924e3f137ba963de82 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Wed, 21 Jul 2021 19:19:05 +1000 Subject: [PATCH 2/5] Recurse into subdirectories with lockfiles --- lib/unwrappr/cli.rb | 51 +++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/lib/unwrappr/cli.rb b/lib/unwrappr/cli.rb index 35312cd..0cdca56 100644 --- a/lib/unwrappr/cli.rb +++ b/lib/unwrappr/cli.rb @@ -31,8 +31,13 @@ class CLI < Clamp::Command subcommand 'all', 'run bundle update, push to github, '\ 'create a pr and annotate changes' do + option ['-R', '--recursive'], + :flag, + 'Recurse into subdirectories', + attribute_name: :recursive + def execute - Unwrappr.run_unwrappr_in_pwd(base_branch: base_branch, lock_files: lock_files) + Unwrappr.run_unwrappr_in_pwd(base_branch: base_branch, lock_files: lock_files, recursive: recursive?) end end @@ -62,33 +67,33 @@ def execute option(['-r', '--repo'], 'REPO', <<~DESCRIPTION, - a repo in github , may be specified multiple times + a repo in GitHub , may be specified multiple times DESCRIPTION required: true, multivalued: true) + option ['-R', '--recursive'], + :flag, + 'Recurse into subdirectories', + attribute_name: :recursive + def execute repo_list.each do |repo| - unless Dir.exist?(repo) - GitCommandRunner.clone_repository( - "https://github.com/#{repo}", - repo - ) - end + GitCommandRunner.clone_repository("https://github.com/#{repo}", repo) unless Dir.exist?(repo) - Dir.chdir(repo) { Unwrappr.run_unwrappr_in_pwd(base_branch: base_branch, lock_files: lock_files) } + Dir.chdir(repo) do + Unwrappr.run_unwrappr_in_pwd(base_branch: base_branch, lock_files: lock_files, recursive: recursive?) + end end end end end - def self.run_unwrappr_in_pwd(base_branch:, lock_files:) + def self.run_unwrappr_in_pwd(base_branch:, lock_files:, recursive:) 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! + bundle_update!(lock_files: lock_files, recursive: recursive) GitCommandRunner.commit_and_push_changes! GitHub::Client.make_pull_request!(lock_files) end @@ -96,4 +101,24 @@ def self.run_unwrappr_in_pwd(base_branch:, lock_files:) def self.any_lockfile_present?(lock_files) lock_files.any? { |lock_file| GitCommandRunner.file_exist?(lock_file) } end + + def self.bundle_update!(lock_files:, recursive:) + directories(lock_files: lock_files, recursive: recursive).each do |dir| + Dir.chdir(dir) do + puts "Doing the unwrappr thing in #{Dir.pwd}" + BundlerCommandRunner.bundle_update! + end + end + end + + def self.directories(lock_files:, recursive:) + if recursive + lock_files + .flat_map { |f| Dir.glob("**/#{f}") } + .map { |f| File.dirname(f) } + .uniq + else + %w[.] + end + end end From 8bbfb5e8ea8376ed91d63908290141c681456e2b Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Wed, 21 Jul 2021 19:19:23 +1000 Subject: [PATCH 3/5] Consistent spelling --- lib/unwrappr/cli.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/unwrappr/cli.rb b/lib/unwrappr/cli.rb index 0cdca56..17dc280 100644 --- a/lib/unwrappr/cli.rb +++ b/lib/unwrappr/cli.rb @@ -29,7 +29,7 @@ class CLI < Clamp::Command exit(0) end - subcommand 'all', 'run bundle update, push to github, '\ + subcommand 'all', 'run bundle update, push to GitHub, '\ 'create a pr and annotate changes' do option ['-R', '--recursive'], :flag, @@ -48,7 +48,7 @@ def execute required: true option ['-p', '--pr'], 'PR', - 'The github PR number', + 'The GitHub PR number', required: true def execute From 4ac127156ad5e7242761c6bb1b92d7ae5dcb7d3f Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Wed, 21 Jul 2021 19:19:42 +1000 Subject: [PATCH 4/5] Bump version --- lib/unwrappr/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/unwrappr/version.rb b/lib/unwrappr/version.rb index 46acd18..a203009 100644 --- a/lib/unwrappr/version.rb +++ b/lib/unwrappr/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Unwrappr - VERSION = '0.7.0' + VERSION = '0.8.0' end From 6dfaa52fb65b94f4271030ca2af728b005a9b34a Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Wed, 21 Jul 2021 19:24:10 +1000 Subject: [PATCH 5/5] Prepare for 0.8.0 release --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e9b6d8..35d9223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -[Unreleased]: https://github.com/envato/unwrappr/compare/v0.7.0...HEAD +[Unreleased]: https://github.com/envato/unwrappr/compare/v0.8.0...HEAD + +## [0.8.0] 2021-07-22 + +### Add + +- Ability to perform a `bundle update` in subdirectories with the `-R` / + `--recursive` flag. ([#90]) + +[0.8.0]: https://github.com/envato/unwrappr/compare/v0.7.0...v0.8.0 +[#90]: https://github.com/envato/unwrappr/pull/90 ## [0.7.0] 2021-07-15