Skip to content

Commit

Permalink
using new git flags
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Sep 3, 2024
1 parent 2b1d275 commit 29c24c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/resolvers/git.cr
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,13 @@ module Shards
end

private def origin_url
@origin_url ||= capture("git ls-remote --get-url origin --bare").strip
@origin_url ||= capture("git ls-remote --get-url origin --bare --git-dir=#{local_path} --work-tree=#{local_path}").strip
end

# Returns whether origin URLs have differing hosts and/or paths.
protected def origin_changed?
Log.debug { "comparing origin_url: '#{origin_url}' with git_url: '#{git_url}'" }

if origin_url == git_url
Log.debug { "#{origin_url} == #{git_url}" }
return false
Expand Down Expand Up @@ -444,11 +446,15 @@ module Shards
raise Error.new("Error missing git command line tool. Please install Git first!")
end

unless path.nil?
Dir.exists?(path) || raise(Error.new("Path #{path} does not exist"))
end

Log.debug { "command: `#{command}` path: `#{path}` capture: `#{capture}` local_path: `#{local_path}`" }

output = capture ? IO::Memory.new : Process::Redirect::Close
error = IO::Memory.new
status = Process.run(command, shell: true, output: output, error: error, chdir: path, env: {"GIT_DIR" => local_path})
status = Process.run(command, shell: true, output: output, error: error, chdir: path)

if status.success?
output.to_s if capture
Expand Down

0 comments on commit 29c24c6

Please sign in to comment.