From e316d7f5f3859eb6cab063a8ebdf09e2ab11640c Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 16 Jun 2024 13:03:57 +0200 Subject: [PATCH 1/4] Add Soviet propaganda --- lib/ff_bot/github/merger.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ff_bot/github/merger.ex b/lib/ff_bot/github/merger.ex index fa7d3ed..a435cdb 100644 --- a/lib/ff_bot/github/merger.ex +++ b/lib/ff_bot/github/merger.ex @@ -44,7 +44,7 @@ defmodule FFBot.GitHub.Merger do pull_request["number"], :success, "Successfully fast-forwarded commits from `#{pull_request["head"]["label"]}` " <> - "onto `#{repo["default_branch"]}`" + "onto `#{repo["default_branch"]}`" <> maybe_propaganda() ) end @@ -66,4 +66,12 @@ defmodule FFBot.GitHub.Merger do defp push_changes(cloned) do {:ok, _} = Git.push(cloned) end + + defp maybe_propaganda do + if :rand.uniform() < 0.01 do + ". Glory to Arstotzka!" + else + "" + end + end end From cba3d572fda99a8b5daf64b07c550145e976cc7b Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 16 Jun 2024 14:56:16 +0200 Subject: [PATCH 2/4] Add FF_NO_PROPAGANDA variable for enemies of the state --- config/runtime.exs | 3 ++- lib/ff_bot/github/merger.ex | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/runtime.exs b/config/runtime.exs index c957b70..c836ae1 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -5,4 +5,5 @@ config :ff_bot, github_client_id: System.fetch_env!("GITHUB_CLIENT_ID"), github_client_secret: System.fetch_env!("GITHUB_CLIENT_SECRET") |> String.replace("\\n", "\n"), policy_file: System.get_env("FF_POLICY_FILE", ".github/ff-bot.yml"), - service_port: System.get_env("FF_LISTEN_PORT", "4000") |> String.to_integer() + service_port: System.get_env("FF_LISTEN_PORT", "4000") |> String.to_integer(), + disable_propaganda?: System.get_env("FF_NO_PROPAGANDA") diff --git a/lib/ff_bot/github/merger.ex b/lib/ff_bot/github/merger.ex index a435cdb..c780995 100644 --- a/lib/ff_bot/github/merger.ex +++ b/lib/ff_bot/github/merger.ex @@ -68,7 +68,7 @@ defmodule FFBot.GitHub.Merger do end defp maybe_propaganda do - if :rand.uniform() < 0.01 do + if Application.get_env(:ff_bot, :disable_propaganda?) != nil and :rand.uniform() < 0.01 do ". Glory to Arstotzka!" else "" From 2dd065203294b3a4dcc2df8fa484645fce19bfdd Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 16 Jun 2024 14:57:36 +0200 Subject: [PATCH 3/4] Document option for enemies of the state --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8b938f7..d9e2716 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,11 @@ The following environment variables must be set: You can also optionally set these variables: -| Variable | Description | Default | -|------------------|-------------------------------------------------------|----------------------| -| `FF_POLICY_FILE` | The file to read for policy on who can perform merges | `.github/ff-bot.yml` | -| `FF_LISTEN_PORT` | The HTTP port for the service to listen on | 4000 | +| Variable | Description | Default | +|--------------------|------------------------------------------------------------------------------------------|----------------------| +| `FF_POLICY_FILE` | The file to read for policy on who can perform merges | `.github/ff-bot.yml` | +| `FF_LISTEN_PORT` | The HTTP port for the service to listen on | 4000 | +| `FF_NO_PROPAGANDA` | Disable all team encouragement messages generated by the bot on merged Pull Requests. | | ## Usage From cdf447557d6b6844c8f4bfa6989d505d072e206a Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 16 Jun 2024 18:26:30 +0200 Subject: [PATCH 4/4] Adjust condition for finding enemies of the state --- lib/ff_bot/github/merger.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ff_bot/github/merger.ex b/lib/ff_bot/github/merger.ex index c780995..33d146b 100644 --- a/lib/ff_bot/github/merger.ex +++ b/lib/ff_bot/github/merger.ex @@ -68,7 +68,7 @@ defmodule FFBot.GitHub.Merger do end defp maybe_propaganda do - if Application.get_env(:ff_bot, :disable_propaganda?) != nil and :rand.uniform() < 0.01 do + if Application.get_env(:ff_bot, :disable_propaganda?) == nil and :rand.uniform() < 0.01 do ". Glory to Arstotzka!" else ""