From 205fc541c9f1c0ceba83521a85b15db89b44ff74 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 17 Sep 2024 07:49:31 +1000 Subject: [PATCH 1/4] Use a Mermaid graph in the backmerge PR body --- ...e_release_backmerge_pull_request_action.rb | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb index 2ead2930e..ddef0789f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb @@ -110,17 +110,41 @@ def self.create_backmerge_pr(token:, repository:, title:, head_branch:, base_bra other_action.push_to_git_remote(tags: false) + # Live playground to edit this graph + # https://mermaid.live/edit#pako:eNqNkU1PwzAMhv9KZanqpWVFwCVHQOKCxoFrLl7itdGaZEoTTWjqf8eLOo2i8eGTPx77TewjKK8JBJTlUbqCzTgTRTEHJ6s6E18C7vtqkc4li8Y9BnSqX6MlBqoYkttV9Y_cW9AUGLxt2_Y7Nfb-8OStNfEVNzQwtcVhpCU1XUJ2p7KU7vzAXNlkmSLQQDjS6v7m4S7nVU9q51O8UsmSv7jzSEuho9Xc3pzaG-Oib_KXlxr_QL8onbuuVy9unvrXbKiBCV645qvme0mIPVmSINjVtMU0RAm8O0YxRf_-4RQIbqca0l5jpGeDXUALIu9_-gRejKzU + meramid_git_graph = <<~GRAPH + ```mermaid + %%{ + init: { + 'gitGraph': { + 'mainBranchName': 'trunk', + 'mainBranchOrder': 1000, + 'showCommitLabel': false + } + } + }%% + gitGraph + branch #{head_branch} + checkout #{head_branch} + commit + commit + commit + branch #{intermediate_branch} + checkout #{intermediate_branch} + commit + checkout #{base_branch} + commit + commit + merge #{base_branch} + ``` + GRAPH + pr_body = <<~BODY Merging `#{head_branch}` into `#{base_branch}`. Via intermediate branch `#{intermediate_branch}`, to help fix conflicts if any: - ``` - #{head_branch.rjust(40)} ----o-- - - - - #{' ' * 40} \\ - #{intermediate_branch.rjust(40)} `---. - #{' ' * 40} \\ - #{base_branch.rjust(40)} ------------x- - - - ``` + + #{meramid_git_graph} BODY other_action.create_pull_request( From a9a887e28a820e39ff757bf558e3b9f60791f2fb Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 17 Sep 2024 07:59:19 +1000 Subject: [PATCH 2/4] Use a `
` node to reintroduce ASCII git graph in backmerge --- ...ate_release_backmerge_pull_request_action.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb index ddef0789f..da2cd6a2a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb @@ -139,12 +139,29 @@ def self.create_backmerge_pr(token:, repository:, title:, head_branch:, base_bra ``` GRAPH + ascii_git_graph = <<~GRAPH + ``` + #{head_branch.rjust(40)} ----o-- - - - + #{' ' * 40} \\ + #{intermediate_branch.rjust(40)} `---. + #{' ' * 40} \\ + #{base_branch.rjust(40)} ------------x- - - + ``` + GRAPH + pr_body = <<~BODY Merging `#{head_branch}` into `#{base_branch}`. Via intermediate branch `#{intermediate_branch}`, to help fix conflicts if any: #{meramid_git_graph} + +
+ Expand to see an ASCII representation of the Git graph above + + #{ascii_git_graph} + +
BODY other_action.create_pull_request( From 4c14ca6b1871cab2a1e6361dd74b78595fd42a8f Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 17 Sep 2024 08:09:13 +1000 Subject: [PATCH 3/4] Add changelog entry for Mermaid git graph in backmerge PR --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e19c8abd..1e9fcf246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ _None_ ### New Features -_None_ +- The backmerge PR body now use a [Mermaid](https://mermaid.js.org) graph to represent the Git tree [#594] ### Bug Fixes From d5ed2079df803833d913c860828461da3adb02bd Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 24 Sep 2024 12:14:04 +1000 Subject: [PATCH 4/4] Fix Mermaid config using hardcoded `trunk` --- .../common/create_release_backmerge_pull_request_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb index da2cd6a2a..48421a992 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb @@ -117,7 +117,7 @@ def self.create_backmerge_pr(token:, repository:, title:, head_branch:, base_bra %%{ init: { 'gitGraph': { - 'mainBranchName': 'trunk', + 'mainBranchName': '#{base_branch}', 'mainBranchOrder': 1000, 'showCommitLabel': false }