Skip to content

Commit

Permalink
try to fix file_exists?
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Sep 3, 2024
1 parent 483bd94 commit cc0a978
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/resolvers/git.cr
Original file line number Diff line number Diff line change
Expand Up @@ -226,27 +226,19 @@ module Shards
@local_path ||= begin
uri = parse_uri(git_url)

Log.debug { "constructing path for #{git_url} - uri: #{uri} - uri.path: #{uri.path} - uri.host #{uri.host}" }

path = uri.path
path += ".git" unless path.ends_with?(".git")
Log.debug { "constructing path part 1: #{path}" }

path = Path[path]
Log.debug { "constructing path part 2: #{path} - type: #{path.class}" }

# E.g. turns "c:\local\path.git" into "c\local\path.git". Or just drops the leading slash.
if (anchor = path.anchor)
path = Path[path.drive.to_s.rchop(":"), path.relative_to(anchor)]
end

Log.debug { "constructing path part 3: #{path} - type: #{path.class}" }

if host = uri.host
Log.debug { "constructing path part 4.1: using host #{host}" }
File.join(Shards.cache_path, host, path)
else
Log.debug { "constructing path part 4.2: using path #{path}" }
File.join(Shards.cache_path, path)
end
end
Expand Down Expand Up @@ -429,7 +421,7 @@ module Shards
end

private def file_exists?(ref : GitRef, path)
files = capture("git ls-tree -r --full-tree --name-only #{Process.quote(ref.to_git_ref)} -- #{Process.quote(path)}")
files = capture("git -C #{local_path} ls-tree -r --full-tree --name-only #{Process.quote(ref.to_git_ref)} -- #{Process.quote(path)}")
!files.strip.empty?
end

Expand Down

0 comments on commit cc0a978

Please sign in to comment.