From f45466f116aac4ee434605d27f3a8969c6009dbe Mon Sep 17 00:00:00 2001 From: pnezis Date: Fri, 4 Oct 2024 16:55:47 +0300 Subject: [PATCH] Fix git commands Changed files were not retrieved properly in latest git versions. --- workspace/lib/workspace/git.ex | 11 +++++++++-- workspace/test/support/test_utils.ex | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/workspace/lib/workspace/git.ex b/workspace/lib/workspace/git.ex index 4e9b872..210314e 100644 --- a/workspace/lib/workspace/git.ex +++ b/workspace/lib/workspace/git.ex @@ -86,7 +86,7 @@ defmodule Workspace.Git do def uncommitted_files(opts \\ []) do cd = opts[:cd] || File.cwd!() - with {:ok, output} <- git_in_path(cd, ~w[diff --name-only --no-renames HEAD .]) do + with {:ok, output} <- git_in_path(cd, ~w[diff --name-only --no-renames HEAD]) do {:ok, parse_git_output(output)} end end @@ -120,7 +120,14 @@ defmodule Workspace.Git do cd = opts[:cd] || File.cwd!() with {:ok, output} <- - git_in_path(cd, ["diff", "--name-only", "--no-renames", "--relative", base, head]) do + git_in_path(cd, [ + "diff", + "--name-only", + "--no-renames", + "--relative", + "#{base}", + "#{head}" + ]) do {:ok, parse_git_output(output)} end end diff --git a/workspace/test/support/test_utils.ex b/workspace/test/support/test_utils.ex index e4558cc..d4dcb93 100644 --- a/workspace/test/support/test_utils.ex +++ b/workspace/test/support/test_utils.ex @@ -188,9 +188,9 @@ defmodule Workspace.TestUtils do def init_git_project(path) do File.cd!(path, fn -> System.cmd("git", ~w[init]) + System.cmd("git", ~w[symbolic-ref HEAD refs/heads/main]) System.cmd("git", ~w[add .]) System.cmd("git", ~w[commit -m "commit"]) - System.cmd("git", ~w[symbolic-ref HEAD refs/heads/main]) end) end