Skip to content
代码片段 群组 项目
提交 62b98459 编辑于 作者: Dylan Griffith's avatar Dylan Griffith
浏览文件

Add standard description/labels to MRs and purple color titles

This adds the `gitlab-housekeeper-authored` label to all MRs and ensures
the commit message and MR always have the housekeeper link included so
that we don't need to add that manually in the keeps anymore.

It also adds some `purple` color to the dry-run output for the titles. This
makes them easier to read.
上级 bd678b15
No related branches found
No related tags found
无相关合并请求
......@@ -34,6 +34,7 @@ PATH
specs:
gitlab-housekeeper (0.1.0)
activesupport
awesome_print
httparty
rubocop
......
......@@ -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)
......
......@@ -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'
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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',
......
......@@ -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
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册