Skip to content

Commit 51cd216

Browse files
author
Christoph Schmatzler
authored
fix(cache): use git index to discover submodule paths in registry release worker (tuist#9494)
1 parent c23cd5b commit 51cd216

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

cache/lib/cache/registry/release_worker.ex

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,21 @@ defmodule Cache.Registry.ReleaseWorker do
168168
end
169169

170170
defp submodule_paths(destination) do
171-
gitmodules_path = Path.join(destination, ".gitmodules")
172-
173-
if File.exists?(gitmodules_path) do
174-
gitmodules_content = File.read!(gitmodules_path)
171+
case System.cmd("git", ["-C", destination, "ls-files", "--stage"], stderr_to_stdout: true) do
172+
{output, 0} ->
173+
output
174+
|> String.split("\n", trim: true)
175+
|> Enum.filter(&String.starts_with?(&1, "160000"))
176+
|> Enum.map(fn line ->
177+
case String.split(line, "\t", parts: 2) do
178+
[_, path] -> String.trim(path)
179+
_ -> nil
180+
end
181+
end)
182+
|> Enum.reject(&is_nil/1)
175183

176-
~r/^\s*path\s*=\s*(.+)\s*$/m
177-
|> Regex.scan(gitmodules_content)
178-
|> Enum.map(fn [_, path] -> String.trim(path) end)
179-
else
180-
[]
184+
_ ->
185+
[]
181186
end
182187
end
183188

0 commit comments

Comments
 (0)