Skip to content

Commit

Permalink
Fix GitResolver#valid_repository? (#646)
Browse files Browse the repository at this point in the history
`git config` exits with status code 1 if the config value was not found. This would raise an exception but instead, `#valid_repository?` should just return `false`. This patch fixes that. It also moves from `--get-regexp` to plain `--get`. The remote name `origin` is fixed anyway (e.g. `git ls-remote --get-url origin` in `#origin_url`) and we only care about this.
  • Loading branch information
straight-shoota authored Oct 8, 2024
1 parent 0f7cabe commit 82db529
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/resolvers/git.cr
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,14 @@ module Shards
end

private def valid_repository?
capture("git config --get-regexp 'remote\\..+\\.mirror'").each_line.any?(&.==("true"))
command = "git config --get remote.origin.mirror"
Log.debug { command }

output = Process.run(command, shell: true, output: :pipe, chdir: local_path) do |process|
process.output.gets_to_end
end

return $?.success? && output.chomp == "true"
end

private def origin_url
Expand Down

0 comments on commit 82db529

Please sign in to comment.