Skip to content

Fix Git discovery & execution on Windows #96

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

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Sources/TSCBasic/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,15 @@ public final class Process: ObjectIdentifierProtocol {
}

// Look for executable.
guard Process.findExecutable(arguments[0]) != nil else {
throw Process.Error.missingExecutableProgram(program: arguments[0])
let executable = arguments[0]
guard let executablePath = Process.findExecutable(executable) else {
throw Process.Error.missingExecutableProgram(program: executable)
}

#if os(Windows)
_process = Foundation.Process()
_process?.arguments = Array(arguments.dropFirst()) // Avoid including the executable URL twice.
_process?.executableURL = URL(fileURLWithPath: arguments[0])
_process?.executableURL = executablePath.asURL
_process?.environment = environment

if outputRedirection.redirectsOutput {
Expand Down
6 changes: 6 additions & 0 deletions Sources/TSCBasic/misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
import TSCLibc
import Foundation

#if os(Windows)
public let executableFileSuffix = ".exe"
#else
public let executableFileSuffix = ""
#endif

/// Replace the current process image with a new process image.
///
/// - Parameters:
Expand Down
2 changes: 1 addition & 1 deletion Sources/TSCUtility/Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Git {
}

/// A shell command to run for Git. Can be either a name or a path.
public static var tool: String = "git"
public static var tool: String = "git\(executableFileSuffix)"

/// Returns true if the git reference name is well formed.
public static func checkRefFormat(ref: String) -> Bool {
Expand Down