Skip to content

Commit

Permalink
Fixes for repository detection on Windows (#136)
Browse files Browse the repository at this point in the history
Merge pull request 136
  • Loading branch information
GICodeWarrior authored and jekyllbot committed Nov 7, 2018
1 parent cd06ca7 commit 2f5745b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion jekyll-github-metadata.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.files = `git ls-files -z`.split("\x0").grep(%r!^(lib|bin)/!)
spec.require_paths = ["lib"]

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

spec.add_development_dependency "bundler", "~> 1.5"
Expand Down
14 changes: 5 additions & 9 deletions lib/jekyll-github-metadata/repository_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ def nwo_from_config
repo if repo && repo.is_a?(String) && repo.include?("/")
end

def git_exe_path
ENV["PATH"].to_s
.split(File::PATH_SEPARATOR)
.map { |path| File.join(path, "git") }
.find { |path| File.exist?(path) }
end

def git_remotes
return [] if git_exe_path.nil?
`#{git_exe_path} remote --verbose`.to_s.strip.split("\n")
_process, output = Jekyll::Utils::Exec.run("git", "remote", "--verbose")
output.to_s.strip.split("\n")
rescue Errno::ENOENT => e
Jekyll.logger.warn "Not Installed:", e.message
[]
end

def git_remote_url
Expand Down
8 changes: 5 additions & 3 deletions spec/repository_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@
end

context "when git doesn't exist" do
before(:each) { @old_path = ENV.delete("PATH").to_s.split(File::PATH_SEPARATOR) }
after(:each) { ENV["PATH"] = @old_path.join(File::PATH_SEPARATOR) }
before(:each) do
@old_path = ENV["PATH"]
ENV["PATH"] = ""
end
after(:each) { ENV["PATH"] = @old_path }

it "fails with a nice error message" do
allow(subject).to receive(:git_remote_url).and_call_original
expect(subject.send(:git_exe_path)).to eql(nil)
expect(subject.send(:git_remote_url)).to be_empty
end
end
Expand Down

0 comments on commit 2f5745b

Please sign in to comment.