From d9a4ff5dde5e83040577804fe3c5923f27dc117b Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sat, 15 Jun 2024 03:35:02 +0100 Subject: [PATCH] Comment on PR on successful merge --- lib/ff_bot/github/merger.ex | 18 ++++++++++++++++-- lib/ff_bot/github/request.ex | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/ff_bot/github/merger.ex b/lib/ff_bot/github/merger.ex index acec516..fa7d3ed 100644 --- a/lib/ff_bot/github/merger.ex +++ b/lib/ff_bot/github/merger.ex @@ -11,6 +11,8 @@ defmodule FFBot.GitHub.Merger do require Logger + alias FFBot.GitHub.Request + def start_merge(token, repo, pull_request) do Logger.metadata( repo: "#{repo["owner"]["login"]}/#{repo["name"]}", @@ -32,6 +34,18 @@ defmodule FFBot.GitHub.Merger do Logger.info("Running clearup") File.rm_rf(directory) + + Logger.info("Send confirmation onto pull request") + + Request.comment( + token, + repo["owner"]["login"], + repo["name"], + pull_request["number"], + :success, + "Successfully fast-forwarded commits from `#{pull_request["head"]["label"]}` " <> + "onto `#{repo["default_branch"]}`" + ) end defp clone_repo(token, repo) do @@ -46,10 +60,10 @@ defmodule FFBot.GitHub.Merger do end defp merge_pull_req(cloned_repo, pull_request) do - Git.merge(cloned_repo, ["--ff-only", "origin/#{pull_request["head"]["ref"]}"]) + {:ok, _} = Git.merge(cloned_repo, ["--ff-only", "origin/#{pull_request["head"]["ref"]}"]) end defp push_changes(cloned) do - Git.push(cloned) + {:ok, _} = Git.push(cloned) end end diff --git a/lib/ff_bot/github/request.ex b/lib/ff_bot/github/request.ex index 49eac09..6796aab 100644 --- a/lib/ff_bot/github/request.ex +++ b/lib/ff_bot/github/request.ex @@ -63,6 +63,7 @@ defmodule FFBot.GitHub.Request do :info -> ":information_source:" :warning -> ":warning:" :error -> ":x:" + :success -> ":white_check_mark:" end request(