Skip to content

Commit

Permalink
Merge pull request #93 from Carthage/fix-submodule-overwriting
Browse files Browse the repository at this point in the history
Delete existing submodule checkouts
  • Loading branch information
jspahrsummers committed Nov 18, 2014
2 parents 5822501 + fe918b1 commit efcc40a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CarthageKit/Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,14 @@ public func cloneSubmoduleInWorkingDirectory(submodule: Submodule, workingDirect
subscriber.put(.Completed)
}

return launchGitTask([ "clone", "--quiet", submodule.URL.URLString, submodule.path ], repositoryFileURL: workingDirectoryURL)
return ColdSignal<String>.lazy {
var error: NSError?
if !NSFileManager.defaultManager().removeItemAtURL(submoduleDirectoryURL, error: &error) {
return .error(error ?? CarthageError.RepositoryCheckoutFailed(workingDirectoryURL: submoduleDirectoryURL, reason: "could not remove submodule checkout").error)
}

return launchGitTask([ "clone", "--quiet", submodule.URL.URLString, submodule.path ], repositoryFileURL: workingDirectoryURL)
}
.then(launchGitTask([ "checkout", "--quiet", submodule.SHA ], repositoryFileURL: submoduleDirectoryURL))
// Clone nested submodules in a separate step, to quiet its output correctly.
.then(launchGitTask([ "submodule", "--quiet", "update", "--init", "--recursive" ], repositoryFileURL: submoduleDirectoryURL))
Expand Down

0 comments on commit efcc40a

Please sign in to comment.