-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for repository detection on Windows #136
Changes from 6 commits
552add8
72b977a
d30a531
e744b52
5310d03
1dcd78e
9ceab82
1f99e1d
147d9fc
5341d34
598bc39
f369e51
27cc2d5
939614d
66e5be6
3f3379b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require "open3" | ||
|
||
module Jekyll | ||
module GitHubMetadata | ||
class RepositoryFinder | ||
|
@@ -46,15 +48,19 @@ def nwo_from_config | |
end | ||
|
||
def git_exe_path | ||
exts = (ENV["PATHEXT"] || "").split(File::PATH_SEPARATOR).push("") | ||
cmds = exts.map { |ext| "git#{ext}" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any known scenario where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really have visibility into how people have their machines setup, but having a Random example: https://gist.github.com/duebbert/c4f26c9d0691b7d4a0e932e7d9f36271 Technically all of the extensions in If you want to simplify it, I recommend skipping the Do you know why this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delegating to Windows can be bothersome IMO. |
||
ENV["PATH"].to_s | ||
.split(File::PATH_SEPARATOR) | ||
.map { |path| File.join(path, "git") } | ||
.find { |path| File.exist?(path) } | ||
.map { |path| cmds.map { |cmd| File.join(path, cmd) } } | ||
.flatten | ||
.find { |path| File.executable?(path) && !File.directory?(path) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this branching really necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Directories are always executable. So if there is a Windows:
Linux:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Today I Learned TM 👍 |
||
end | ||
|
||
def git_remotes | ||
return [] if git_exe_path.nil? | ||
`#{git_exe_path} remote --verbose`.to_s.strip.split("\n") | ||
output, _status = Open3.capture2(git_exe_path, "remote", "--verbose") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @parkr @benbalter Can we drop support for Jekyll versions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, as GitHub pages uses currently |
||
output.to_s.strip.split("\n") | ||
DirtyF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
def git_remote_url | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PATHEXT
on Windows is a list of file extensions respected by cmd.exe.http://environmentvariables.org/PathExt
This code splits PATHEXT into an array of extensions and adds a blank extension to the end (for odd Windows setups and normal non-Windows setups).
On non-Windows platforms
exts
is only[""]
.