Skip to content

Commit 2f5745b

Browse files
GICodeWarriorjekyllbot
authored andcommitted
Fixes for repository detection on Windows (#136)
Merge pull request 136
1 parent cd06ca7 commit 2f5745b

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

jekyll-github-metadata.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
1616
spec.files = `git ls-files -z`.split("\x0").grep(%r!^(lib|bin)/!)
1717
spec.require_paths = ["lib"]
1818

19-
spec.add_runtime_dependency "jekyll", ENV["JEKYLL_VERSION"] ? "~> #{ENV["JEKYLL_VERSION"]}" : "~> 3.1"
19+
spec.add_runtime_dependency "jekyll", ENV["JEKYLL_VERSION"] ? "~> #{ENV["JEKYLL_VERSION"]}" : "~> 3.4"
2020
spec.add_runtime_dependency "octokit", "~> 4.0", "!= 4.4.0"
2121

2222
spec.add_development_dependency "bundler", "~> 1.5"

lib/jekyll-github-metadata/repository_finder.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@ def nwo_from_config
4545
repo if repo && repo.is_a?(String) && repo.include?("/")
4646
end
4747

48-
def git_exe_path
49-
ENV["PATH"].to_s
50-
.split(File::PATH_SEPARATOR)
51-
.map { |path| File.join(path, "git") }
52-
.find { |path| File.exist?(path) }
53-
end
54-
5548
def git_remotes
56-
return [] if git_exe_path.nil?
57-
`#{git_exe_path} remote --verbose`.to_s.strip.split("\n")
49+
_process, output = Jekyll::Utils::Exec.run("git", "remote", "--verbose")
50+
output.to_s.strip.split("\n")
51+
rescue Errno::ENOENT => e
52+
Jekyll.logger.warn "Not Installed:", e.message
53+
[]
5854
end
5955

6056
def git_remote_url

spec/repository_finder_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@
7777
end
7878

7979
context "when git doesn't exist" do
80-
before(:each) { @old_path = ENV.delete("PATH").to_s.split(File::PATH_SEPARATOR) }
81-
after(:each) { ENV["PATH"] = @old_path.join(File::PATH_SEPARATOR) }
80+
before(:each) do
81+
@old_path = ENV["PATH"]
82+
ENV["PATH"] = ""
83+
end
84+
after(:each) { ENV["PATH"] = @old_path }
8285

8386
it "fails with a nice error message" do
8487
allow(subject).to receive(:git_remote_url).and_call_original
85-
expect(subject.send(:git_exe_path)).to eql(nil)
8688
expect(subject.send(:git_remote_url)).to be_empty
8789
end
8890
end

0 commit comments

Comments
 (0)