diff --git a/config/dev.exs b/config/dev.exs
index 4a5d86d..462b9aa 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -24,11 +24,11 @@ config :kmxgit, KmxgitWeb.Endpoint,
watchers: [
sass: {
DartSass,
- :install_and_run,
+ :run,
[:default, ~w(--embed-source-map --source-map-urls=absolute --watch)]
},
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
- esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}
+ esbuild: {Esbuild, :run, [:default, ~w(--sourcemap=inline --watch)]}
]
# ## SSL Support
diff --git a/lib/kmxgit/git_manager.ex b/lib/kmxgit/git_manager.ex
index 0aba0d2..e6a2d3b 100644
--- a/lib/kmxgit/git_manager.ex
+++ b/lib/kmxgit/git_manager.ex
@@ -271,4 +271,13 @@ defmodule Kmxgit.GitManager do
commit
|> Map.put(:tag, tag)
end
+
+ def diff(repo, from, to) do
+ dir = git_dir(repo)
+ {out, status} = System.cmd("git", ["-C", dir, "diff", from, to], stderr_to_stdout: true)
+ case status do
+ 0 -> {:ok, out}
+ _ -> {:error, out}
+ end
+ end
end
diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index cd4ba57..5e29514 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -316,10 +316,14 @@ defmodule KmxgitWeb.RepositoryController do
end
end
defp show_op(conn, :commit, _branch, git, org, _path, repo, _user) do
+ IO.inspect(git)
+ {:ok, diff} = GitManager.diff(Repository.full_slug(repo), git.log1.hash, "#{git.log1.hash}~1")
+ diff_html = Pygmentize.html(diff, "diff.patch")
conn
|> assign(:commit, git.log1)
|> assign_current_organisation(org)
|> assign(:current_repository, repo)
+ |> assign(:diff_html, diff_html)
|> assign(:repo, repo)
|> render("commit.html")
end
diff --git a/lib/kmxgit_web/templates/repository/commit.html.heex b/lib/kmxgit_web/templates/repository/commit.html.heex
index 15d4cb2..ea49b5a 100644
--- a/lib/kmxgit_web/templates/repository/commit.html.heex
+++ b/lib/kmxgit_web/templates/repository/commit.html.heex
@@ -14,6 +14,7 @@
<p>
<%= @commit.message %>
</p>
+ <%= raw @diff_html %>
<hr/>
</div>
<div class="col col-12 col-md-5">
diff --git a/mix.exs b/mix.exs
index b193804..66af664 100644
--- a/mix.exs
+++ b/mix.exs
@@ -34,9 +34,11 @@ defmodule Kmxgit.MixProject do
defp deps do
[
{:bcrypt_elixir, "~> 2.0"},
+ {:dart_sass, "~> 0.2", runtime: Mix.env() == :dev},
{:earmark, "~> 1.4.5"},
{:ecto_sql, "~> 3.6"},
{:elixir_auth_google, "~> 1.6.2"},
+ {:esbuild, "~> 0.2", runtime: Mix.env() == :dev},
{:floki, ">= 0.30.0", only: :test},
{:gen_smtp, "~> 1.1"},
{:gettext, "~> 0.18"},
@@ -72,8 +74,8 @@ defmodule Kmxgit.MixProject do
"ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
"assets.deploy": [
- "esbuild default --minify",
- "sass default --no-source-map --style=compressed",
+ "esbuild assets/js/app.js priv/static/_assets/app.js --minify",
+ "sass assets/css/app.scss priv/static/_assets/app.css --no-source-map --style=compressed",
"phx.digest"
]
]