fix: added homebrew to path for git
This commit is contained in:
@@ -429,11 +429,21 @@ defmodule BDS.Git do
|
|||||||
env: %{
|
env: %{
|
||||||
"GIT_TERMINAL_PROMPT" => "0",
|
"GIT_TERMINAL_PROMPT" => "0",
|
||||||
"GCM_INTERACTIVE" => "never",
|
"GCM_INTERACTIVE" => "never",
|
||||||
"GIT_SSH_COMMAND" => ssh_command
|
"GIT_SSH_COMMAND" => ssh_command,
|
||||||
|
"PATH" => git_path()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A macOS app launched from Finder inherits a minimal PATH and never sources
|
||||||
|
# the login shell, so Homebrew tools like git-lfs (called from git hooks) are
|
||||||
|
# not found. Prepend the standard Homebrew bin dirs to the inherited PATH.
|
||||||
|
defp git_path do
|
||||||
|
["/opt/homebrew/bin", "/usr/local/bin", System.get_env("PATH") || ""]
|
||||||
|
|> Enum.reject(&(&1 == ""))
|
||||||
|
|> Enum.join(":")
|
||||||
|
end
|
||||||
|
|
||||||
defp upstream_branch(project_dir, opts) do
|
defp upstream_branch(project_dir, opts) do
|
||||||
case run_git(
|
case run_git(
|
||||||
project_dir,
|
project_dir,
|
||||||
|
|||||||
@@ -193,6 +193,9 @@ defmodule BDS.GitTest do
|
|||||||
assert fetch_opts[:env]["GIT_TERMINAL_PROMPT"] == "0"
|
assert fetch_opts[:env]["GIT_TERMINAL_PROMPT"] == "0"
|
||||||
assert fetch_opts[:env]["GCM_INTERACTIVE"] == "never"
|
assert fetch_opts[:env]["GCM_INTERACTIVE"] == "never"
|
||||||
assert fetch_opts[:env]["GIT_SSH_COMMAND"] =~ "BatchMode=yes"
|
assert fetch_opts[:env]["GIT_SSH_COMMAND"] =~ "BatchMode=yes"
|
||||||
|
# git hooks (e.g. git-lfs pre-push) must find Homebrew tools even when the
|
||||||
|
# app is launched from Finder with a minimal PATH.
|
||||||
|
assert fetch_opts[:env]["PATH"] =~ "/opt/homebrew/bin"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "fetch returns structured auth errors with provider guidance", %{project: project} do
|
test "fetch returns structured auth errors with provider guidance", %{project: project} do
|
||||||
|
|||||||
Reference in New Issue
Block a user