Commit f927ffb6f79dbf98954ccaf1c98dd81e1df6fb1e

Thomas de Grivel 2021-12-11T17:43:11

remove \r in authorized_keys

diff --git a/lib/kmxgit/repository_manager/repository.ex b/lib/kmxgit/repository_manager/repository.ex
index 7a485ad..7dbf37b 100644
--- a/lib/kmxgit/repository_manager/repository.ex
+++ b/lib/kmxgit/repository_manager/repository.ex
@@ -184,10 +184,11 @@ defmodule Kmxgit.RepositoryManager.Repository do
     (repo.deploy_keys || "")
     |> String.split("\n")
     |> Enum.map(fn line ->
-      if Regex.match?(~r/^[ \t]*ssh-/, line) do
-        "environment=\"GIT_AUTH_ID=#{deploy_user(repo)}\" #{line}"
+      line1 = String.replace(line, "\r", "")
+      if Regex.match?(~r/^[ \t]*ssh-/, line1) do
+        "environment=\"GIT_AUTH_ID=#{deploy_user(repo)}\" #{line1}"
       else
-        line
+        line1
       end
     end)
     |> Enum.join("\n")
diff --git a/lib/kmxgit/user_manager/user.ex b/lib/kmxgit/user_manager/user.ex
index 6269be5..4432431 100644
--- a/lib/kmxgit/user_manager/user.ex
+++ b/lib/kmxgit/user_manager/user.ex
@@ -183,10 +183,11 @@ defmodule Kmxgit.UserManager.User do
     (user.ssh_keys || "")
     |> String.split("\n")
     |> Enum.map(fn line ->
-      if Regex.match?(~r/^[ \t]*ssh-/, line) do
-        "environment=\"GIT_AUTH_ID=#{user.slug.slug}\" #{line}"
+      line1 = String.replace(line, "\r", "")
+      if Regex.match?(~r/^[ \t]*ssh-/, line1) do
+        "environment=\"GIT_AUTH_ID=#{user.slug.slug}\" #{line1}"
       else
-        line
+        line1
       end
     end)
     |> Enum.join("\n")