diff --git a/Gemfile.lock b/Gemfile.lock index 6cd5f3e16f32ab2e3b36d3f31019da0c97bab372..4c734a403d2d3729e8c03beced12f8d22a4b76ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,6 +34,7 @@ PATH specs: gitlab-housekeeper (0.1.0) activesupport + awesome_print httparty rubocop diff --git a/gems/gitlab-housekeeper/Gemfile.lock b/gems/gitlab-housekeeper/Gemfile.lock index 9fbdc2468119ed9218e5f15836848e2823069d0f..292bfdd6eebc0e999bb888dae71d7deecd61ad85 100644 --- a/gems/gitlab-housekeeper/Gemfile.lock +++ b/gems/gitlab-housekeeper/Gemfile.lock @@ -11,6 +11,7 @@ PATH specs: gitlab-housekeeper (0.1.0) activesupport + awesome_print httparty rubocop @@ -30,6 +31,7 @@ GEM addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) + awesome_print (1.9.2) coderay (1.1.3) concurrent-ruby (1.2.2) crack (0.4.3) diff --git a/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec b/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec index 4083b3c2d11dbba80866dbfe6c3abb6bcd68bdbf..ca78d3136b7c6886026f4e014ed721104f9c6d8f 100644 --- a/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec +++ b/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec @@ -22,6 +22,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'activesupport' spec.add_runtime_dependency 'httparty' spec.add_runtime_dependency 'rubocop' + spec.add_runtime_dependency 'awesome_print' spec.add_development_dependency 'gitlab-styles' spec.add_development_dependency 'rspec-rails' diff --git a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb index 94bddbaf95fc12be1135a1162892c9821e7434cf..329d32885eeefd3c4da3f42beb41f26110057f1b 100644 --- a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb +++ b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb @@ -49,11 +49,6 @@ def create_commit(branch_name, change) #{change.title} #{change.description} - - This commit was generated by - [gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139492). - - Changelog: other MSG Shell.execute("git", "commit", "-m", commit_message) diff --git a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/runner.rb b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/runner.rb index 1be94e15f3783a2d82da7af353f48591c6d79f8d..cebe2acfe5b6f88dfaef464a2d0c76def44ffff6 100644 --- a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/runner.rb +++ b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/runner.rb @@ -4,6 +4,7 @@ require 'gitlab/housekeeper/keep' require 'gitlab/housekeeper/gitlab_client' require 'gitlab/housekeeper/git' +require 'awesome_print' require 'digest' module Gitlab @@ -32,6 +33,7 @@ def run keep = keep_class.new keep.each_change do |change| branch_name = git.commit_in_branch(change) + add_standard_change_data(change) if @dry_run dry_run(change, branch_name) @@ -49,6 +51,19 @@ def run puts "Housekeeper created #{created} MRs" end + def add_standard_change_data(change) + change.labels ||= [] + change.labels << 'automation:gitlab-housekeeper-authored' + + change.description += <<~MARKDOWN + + This change was generated by + [gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/tree/master/gems/gitlab-housekeeper) + + Changelog: other + MARKDOWN + end + def git @git ||= ::Gitlab::Housekeeper::Git.new(logger: @logger) end @@ -60,22 +75,22 @@ def require_keeps(files) end def dry_run(change, branch_name) - puts "=> #{change.identifiers.join(': ')}" + puts "=> #{change.identifiers.join(': ')}".purple - if change.labels.present? - puts '=> Attributes:' - puts "Labels: #{change.labels.join(', ')}" - puts - end - - puts '=> Title:' - puts change.title + puts '=> Title:'.purple + puts change.title.purple puts puts '=> Description:' puts change.description puts + if change.labels.present? + puts '=> Attributes:' + puts "Labels: #{change.labels.join(', ')}" + puts + end + puts '=> Diff:' puts Shell.execute('git', '--no-pager', 'diff', '--color=always', 'master', branch_name, '--', *change.changed_files) diff --git a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb index 8cf69d2b62c49bbdc321a06617cad58936b7f5e0..485c46f7ad0f3d9e25067175d9b2b943655be1b0 100644 --- a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb +++ b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb @@ -92,11 +92,6 @@ def setup_and_checkout_another_branch split over multiple lines! - This commit was generated by - [gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139492). - - Changelog: other - diff --git a/files/test_file2.txt b/files/test_file2.txt new file mode 100644 index 0000000..ff205e0 diff --git a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/runner_spec.rb b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/runner_spec.rb index d3267cb001f2eaf5381aaa39b3da4236530d4886..51dcc3b763f9669419747e7bfa2194166b400d6b 100644 --- a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/runner_spec.rb +++ b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/runner_spec.rb @@ -100,8 +100,8 @@ .with( source_project_id: '123', title: 'The title of MR1', - description: 'The description of the MR', - labels: ['example-label'], + description: /The description of the MR/, + labels: %w[example-label automation:gitlab-housekeeper-authored], source_branch: 'the-identifier-for-the-first-change', target_branch: 'master', target_project_id: '456', @@ -113,8 +113,8 @@ .with( source_project_id: '123', title: 'The title of MR2', - description: 'The description of the MR', - labels: ['example-label'], + description: /The description of the MR/, + labels: %w[example-label automation:gitlab-housekeeper-authored], source_branch: 'the-identifier-for-the-second-change', target_branch: 'master', target_project_id: '456', @@ -157,8 +157,8 @@ .with( source_project_id: '123', title: 'The title of MR1', - description: 'The description of the MR', - labels: ['example-label'], + description: /The description of the MR/, + labels: %w[example-label automation:gitlab-housekeeper-authored], source_branch: 'the-identifier-for-the-first-change', target_branch: 'master', target_project_id: '456', @@ -170,8 +170,8 @@ .with( source_project_id: '123', title: 'The title of MR2', - description: 'The description of the MR', - labels: ['example-label'], + description: /The description of the MR/, + labels: %w[example-label automation:gitlab-housekeeper-authored], source_branch: 'the-identifier-for-the-second-change', target_branch: 'master', target_project_id: '456', diff --git a/keeps/overdue_finalize_background_migration.rb b/keeps/overdue_finalize_background_migration.rb index aaaa9ab115937836f353548526a98316a6d91c9b..5cfeca0b41bffd25648838841c3fef12994854fa 100644 --- a/keeps/overdue_finalize_background_migration.rb +++ b/keeps/overdue_finalize_background_migration.rb @@ -66,10 +66,6 @@ def each_change [required stop](https://docs.gitlab.com/ee/development/database/required_stops.html) to process the migration. Therefore we can finalize any batched background migration that was added before the last required stop. - - This merge request was created using the - [gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139492) - gem. MARKDOWN # rubocop:enable Gitlab/DocUrl