Skip to content

Commit

Permalink
Fix pretty sync message to github
Browse files Browse the repository at this point in the history
  • Loading branch information
zacck committed Aug 23, 2023
1 parent b501546 commit 5f50249
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 8 additions & 5 deletions lib/lightning/version_control/github_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule Lightning.VersionControl.GithubClient do
to github from Lightning
"""
use Tesla
require Logger
alias Lightning.VersionControl.GithubToken

plug(Tesla.Middleware.BaseUrl, "https://api.github.com")
Expand Down Expand Up @@ -45,14 +46,15 @@ defmodule Lightning.VersionControl.GithubClient do
end
end

def fire_repository_dispatch(installation_id, repo_name, user_name) do
def fire_repository_dispatch(installation_id, repo_name, user_email) do
with {:ok, installation_client} <- build_client(installation_id),
{:ok, %{status: 204}} <-
installation_client
|> post("/repos/#{repo_name}/dispatches", %{
event_type: "Sync by: #{user_name}",
client_payload:
"#{user_name} is synced a new project spec and state"
event_type: "Sync by: #{user_email}",
client_payload: %{
message: "#{user_email} initiated a sync from Lightning"
}
}) do
{:ok, :fired}
else
Expand All @@ -62,7 +64,8 @@ defmodule Lightning.VersionControl.GithubClient do
{:error, :invalid_pem} ->
invalid_pem_error()

_ ->
err ->
Logger.error(inspect(err))

Check warning on line 68 in lib/lightning/version_control/github_client.ex

View check run for this annotation

Codecov / codecov/patch

lib/lightning/version_control/github_client.ex#L68

Added line #L68 was not covered by tests
{:error, "Error Initiating sync"}
end
end
Expand Down
4 changes: 1 addition & 3 deletions lib/lightning_web/live/project_live/settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ defmodule LightningWeb.ProjectLive.Settings do
end

def handle_event("run_sync", params, %{assigns: %{current_user: u}} = socket) do
user_name = u.first_name <> " " <> u.last_name

case VersionControl.run_sync(params["id"], user_name) do
case VersionControl.run_sync(params["id"], u.email) do

Check warning on line 332 in lib/lightning_web/live/project_live/settings.ex

View check run for this annotation

Codecov / codecov/patch

lib/lightning_web/live/project_live/settings.ex#L332

Added line #L332 was not covered by tests
{:ok, :fired} ->
{:noreply, socket |> put_flash(:info, "Sync Initialized")}

Expand Down

0 comments on commit 5f50249

Please sign in to comment.