Skip to content

Commit

Permalink
Re-download checkout if failing to reset
Browse files Browse the repository at this point in the history
  • Loading branch information
fredpi committed May 1, 2019
1 parent a83d11f commit 80bb12a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Sources/AccioKit/Commands/Protocols/DependencyInstaller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ extension DependencyInstaller {
let frameworkCheckoutPath: String = checkoutsDirUrl.appendingPathComponent(fileName).path

if try FileManager.default.isDirectory(atPath: frameworkCheckoutPath) {
try bash("git -C '\(frameworkCheckoutPath)' reset HEAD --hard --quiet 2> /dev/null")
try bash("git -C '\(frameworkCheckoutPath)' clean -fd --quiet 2> /dev/null")
try bash("git -C '\(frameworkCheckoutPath)' clean -fdX --quiet 2> /dev/null")
do {
try bash("git -C '\(frameworkCheckoutPath)' reset HEAD --hard --quiet 2> /dev/null")
try bash("git -C '\(frameworkCheckoutPath)' clean -fd --quiet 2> /dev/null")
try bash("git -C '\(frameworkCheckoutPath)' clean -fdX --quiet 2> /dev/null")
}
catch {
// Remove checkout if git reset fails for some reason
// If the checkout is missing, SPM will automatically clone again in the next step
FileManager.default.removeItem(atPath: frameworkCheckoutPath)
}
}
}
}
Expand Down

0 comments on commit 80bb12a

Please sign in to comment.