Skip to content

Commit 82db529

Browse files
Fix GitResolver#valid_repository? (#646)
`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.
1 parent 0f7cabe commit 82db529

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/resolvers/git.cr

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,14 @@ module Shards
351351
end
352352

353353
private def valid_repository?
354-
capture("git config --get-regexp 'remote\\..+\\.mirror'").each_line.any?(&.==("true"))
354+
command = "git config --get remote.origin.mirror"
355+
Log.debug { command }
356+
357+
output = Process.run(command, shell: true, output: :pipe, chdir: local_path) do |process|
358+
process.output.gets_to_end
359+
end
360+
361+
return $?.success? && output.chomp == "true"
355362
end
356363

357364
private def origin_url

0 commit comments

Comments
 (0)