-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339: CloneVerb: Fall back to partial clone
This requires microsoft/git#249 in order to avoid a bad partial clone bug. You can now try this: ``` $ scalar clone https://github.com/microsoft/scalar Clone parameters: Repo URL: https://github.com/microsoft/scalar Branch: Default Cache Server: Default Local Cache: C:\.scalarCache Destination: C:\_git\t\scalar FullClone: False Authenticating...Succeeded Fetching objects from remote...Succeeded Checking out 'master'...Succeeded $ ls scalar/src/ AuthoringTests.md Dependencies.props Directory.Build.targets License.md Protocol.md Scalar.ruleset SECURITY.md CONTRIBUTING.md Directory.Build.props global.json nuget.config Readme.md Scalar.sln Signing.targets $ cd scalar/src/ $ git sparse-checkout disable remote: Enumerating objects: 418, done. remote: Counting objects: 100% (418/418), done. remote: Compressing objects: 100% (410/410), done. remote: Total 483 (delta 71), reused 9 (delta 8), pack-reused 65 Receiving objects: 100% (483/483), 556.94 KiB | 8.57 MiB/s, done. Resolving deltas: 100% (77/77), done. Updating files: 100% (491/491), done. $ ls AuthoringTests.md global.json Scalar.Common/ Scalar.ruleset Scalar.UnitTests/ CONTRIBUTING.md License.md Scalar.FunctionalTests/ Scalar.Service/ Scalar.Upgrader/ Dependencies.props nuget.config Scalar.Installer.Mac/ Scalar.Service.UI/ Scripts/ Directory.Build.props Protocol.md Scalar.Installer.Windows/ Scalar.Signing/ SECURITY.md Directory.Build.targets Readme.md Scalar.MSBuild/ Scalar.sln Signing.targets docs/ Scalar/ Scalar.Notifications.Mac/ Scalar.TestInfrastructure/ ``` or use SSH: ``` $ scalar clone [email protected]:microsoft/scalar.git scalar-ssh Clone parameters: Repo URL: [email protected]:microsoft/scalar.git Branch: Default Cache Server: Default Local Cache: C:\.scalarCache Destination: C:\_git\t\scalar-ssh FullClone: False Fetching objects from remote...Succeeded Checking out 'master'...Succeeded $ cd scalar-ssh/src/ $ ls AuthoringTests.md Dependencies.props Directory.Build.targets License.md Protocol.md Scalar.ruleset SECURITY.md CONTRIBUTING.md Directory.Build.props global.json nuget.config Readme.md Scalar.sln Signing.targets $ git sparse-checkout disable remote: Enumerating objects: 418, done. remote: Counting objects: 100% (418/418), done. remote: Compressing objects: 100% (410/410), done. remote: Total 483 (delta 71), reused 9 (delta 8), pack-reused 65 Receiving objects: 100% (483/483), 556.94 KiB | 9.95 MiB/s, done. Resolving deltas: 100% (77/77), done. Updating files: 100% (491/491), done. $ ls AuthoringTests.md global.json Scalar.Common/ Scalar.ruleset Scalar.UnitTests/ CONTRIBUTING.md License.md Scalar.FunctionalTests/ Scalar.Service/ Scalar.Upgrader/ Dependencies.props nuget.config Scalar.Installer.Mac/ Scalar.Service.UI/ Scripts/ Directory.Build.props Protocol.md Scalar.Installer.Windows/ Scalar.Signing/ SECURITY.md Directory.Build.targets Readme.md Scalar.MSBuild/ Scalar.sln Signing.targets docs/ Scalar/ Scalar.Notifications.Mac/ Scalar.TestInfrastructure/ ``` I test a scenario for HTTPS clones, but SSH clones don't work due to the protections against man-in-the-middle attacks. Not sure how to resolve that, but the test I had would work from my dev box that had GitHub.com in my `known_hosts` file.
- Loading branch information
Showing
10 changed files
with
254 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
Scalar.FunctionalTests/Tests/MultiEnlistmentTests/ScalarCloneFromGithub.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using NUnit.Framework; | ||
using Scalar.FunctionalTests.FileSystemRunners; | ||
using Scalar.FunctionalTests.Tools; | ||
using Scalar.Tests.Should; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace Scalar.FunctionalTests.Tests.MultiEnlistmentTests | ||
{ | ||
[Category(Categories.GitRepository)] | ||
public class ScalarCloneFromGithub : TestsWithMultiEnlistment | ||
{ | ||
private static readonly string MicrosoftScalarHttp = "https://github.com/microsoft/scalar"; | ||
private static readonly string MicrosoftScalarSsh = "[email protected]:microsoft/scalar.git"; | ||
|
||
private FileSystemRunner fileSystem; | ||
|
||
public ScalarCloneFromGithub() | ||
{ | ||
this.fileSystem = new SystemIORunner(); | ||
} | ||
|
||
[TestCase] | ||
public void PartialCloneHttps() | ||
{ | ||
ScalarFunctionalTestEnlistment enlistment = this.CreateNewEnlistment( | ||
url: MicrosoftScalarHttp, | ||
branch: "master", | ||
fullClone: false); | ||
|
||
VerifyPartialCloneBehavior(enlistment); | ||
} | ||
|
||
private void VerifyPartialCloneBehavior(ScalarFunctionalTestEnlistment enlistment) | ||
{ | ||
this.fileSystem.DirectoryExists(enlistment.RepoRoot).ShouldBeTrue($"'{enlistment.RepoRoot}' does not exist"); | ||
|
||
string gitPack = Path.Combine(enlistment.RepoRoot, ".git", "objects", "pack"); | ||
this.fileSystem.DirectoryExists(gitPack).ShouldBeTrue($"'{gitPack}' does not exist"); | ||
|
||
void checkPacks(string dir, int count, string when) | ||
{ | ||
string dirContents = this.fileSystem | ||
.EnumerateDirectory(dir); | ||
|
||
dirContents | ||
.Split() | ||
.Where(file => string.Equals(Path.GetExtension(file), ".pack", StringComparison.OrdinalIgnoreCase)) | ||
.Count() | ||
.ShouldEqual(count, $"'{dir}' after '{when}': '{dirContents}'"); | ||
} | ||
|
||
// Two packs for clone: commits and trees, blobs at root | ||
checkPacks(gitPack, 2, "clone"); | ||
|
||
string srcScalar = Path.Combine(enlistment.RepoRoot, "Scalar"); | ||
this.fileSystem.DirectoryExists(srcScalar).ShouldBeFalse($"'{srcScalar}' should not exist due to sparse-checkout"); | ||
|
||
ProcessResult sparseCheckoutResult = GitProcess.InvokeProcess(enlistment.RepoRoot, "sparse-checkout disable"); | ||
sparseCheckoutResult.ExitCode.ShouldEqual(0, "git sparse-checkout disable exit code"); | ||
|
||
this.fileSystem.DirectoryExists(srcScalar).ShouldBeTrue($"'{srcScalar}' should exist after sparse-checkout"); | ||
|
||
// Three packs for sparse-chekcout: commits and trees, blobs at root, blobs outside root | ||
checkPacks(gitPack, 3, "sparse-checkout"); | ||
|
||
ProcessResult checkoutResult = GitProcess.InvokeProcess(enlistment.RepoRoot, "checkout HEAD~10"); | ||
checkoutResult.ExitCode.ShouldEqual(0, "git checkout exit code"); | ||
|
||
// Four packs for chekcout: commits and trees, blobs at root, blobs outside root, checkout diff | ||
checkPacks(gitPack, 4, "checkout"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.