Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
simonprev committed Dec 22, 2023
1 parent 959a83a commit 7dc0596
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 30 deletions.
2 changes: 0 additions & 2 deletions lib/accent/translations/translations_renderer.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
defmodule Accent.TranslationsRenderer do
@moduledoc false
alias Langue

def render_entries(args) do
{:ok, serializer} = Langue.serializer_from_format(args.document.format)

Expand Down
19 changes: 10 additions & 9 deletions lib/hook/inbounds/github.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ defmodule Accent.Hook.Inbounds.GitHub do

def fetch_content(path, token) do
with {:ok, %{body: %{"content" => content}}} <- file_server().get_path(path, headers(token)),
decoded_contents <-
decoded_contents =
content
|> String.split("\n")
|> Enum.reject(&(&1 === ""))
|> Enum.map(&Base.decode64/1),
true <- Enum.all?(decoded_contents, &match?({:ok, _}, &1)),
decoded_content <- Enum.map_join(decoded_contents, "", &elem(&1, 1)) do
true <- Enum.all?(decoded_contents, &match?({:ok, _}, &1)) do
decoded_content = Enum.map_join(decoded_contents, "", &elem(&1, 1))
{:ok, decoded_content}
else
_ -> {:ok, nil}
Expand Down Expand Up @@ -101,8 +101,9 @@ defmodule Accent.Hook.Inbounds.GitHub do
end

defp fetch_config(repo, token, ref) do
with path <- Path.join([repo, "contents", "accent.json"]) <> "?ref=#{ref}",
{:ok, config} when is_binary(config) <- fetch_content(path, token),
path = Path.join([repo, "contents", "accent.json"]) <> "?ref=#{ref}"

with {:ok, config} when is_binary(config) <- fetch_content(path, token),
{:ok, %{"files" => files}} <- Jason.decode(config) do
files
else
Expand All @@ -111,10 +112,10 @@ defmodule Accent.Hook.Inbounds.GitHub do
end

defp fetch_trees(repo, token, ref) do
with path <- Path.join([repo, "git", "trees", ref]) <> "?recursive=1",
{:ok, %{body: %{"tree" => tree}}} <- file_server().get_path(path, headers(token)) do
Enum.filter(tree, &(&1["type"] === "blob"))
else
path = Path.join([repo, "git", "trees", ref]) <> "?recursive=1"

case file_server().get_path(path, headers(token)) do
{:ok, %{body: %{"tree" => tree}}} -> Enum.filter(tree, &(&1["type"] === "blob"))
_ -> []
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/hook/inbounds/github/add_translations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ defmodule Accent.Hook.Inbounds.GitHub.AddTranslations do
defp build_context(file, project, token, format) do
with {:ok, parser} <- Langue.parser_from_format(format),
%{id: id} = document when not is_nil(id) <- GitHub.movement_document(project, file["path"]),
document <- %{document | format: format},
document = %{document | format: format},
{:ok, file_content} <- GitHub.fetch_content(file["url"], token),
%{entries: entries} <- MovementContextParser.to_entries(document, file_content, parser) do
%Context{
Expand Down
4 changes: 2 additions & 2 deletions lib/hook/inbounds/github/sync.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ defmodule Accent.Hook.Inbounds.GitHub.Sync do

defp build_context(file, project, token, format) do
with {:ok, parser} <- Langue.parser_from_format(format),
document <- GitHub.movement_document(project, file["path"]),
document <- %{document | format: format},
document = GitHub.movement_document(project, file["path"]),
document = %{document | format: format},
{:ok, file_content} <- GitHub.fetch_content(file["url"], token),
%{entries: entries, document: parsed_document} <-
MovementContextParser.to_entries(document, file_content, parser) do
Expand Down
2 changes: 1 addition & 1 deletion lib/movement/context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ defmodule Movement.Context do
@type t :: %__MODULE__{}

def assign(context, key, value) do
Map.put(context, :assigns, Map.merge(context.assigns, %{key => value}))
Map.put(context, :assigns, Map.put(context.assigns, key, value))
end
end
26 changes: 13 additions & 13 deletions mix.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/auth/user_remote/token_giver_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule AccentTest.UserRemote.TokenGiver do

test "revoke existing token" do
user = Repo.insert!(@user)
token = Repo.insert!(Map.merge(@token, %{user_id: user.id}))
token = Repo.insert!(Map.put(@token, :user_id, user.id))

existing_revoked_token =
Repo.insert!(%AccessToken{token: "revoked", revoked_at: NaiveDateTime.utc_now(:second), user_id: user.id})
Expand Down
2 changes: 1 addition & 1 deletion test/plugs/assign_current_user_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule AccentTest.Plugs.AssignCurrentUser do
|> Repo.insert!()
|> Map.put(:permissions, %{})

token = Repo.insert!(Map.merge(@token, %{user_id: user.id}))
token = Repo.insert!(Map.put(@token, :user_id, user.id))

assigned_user =
token.token
Expand Down

0 comments on commit 7dc0596

Please sign in to comment.