public static void ManualTest() { Console.WriteLine($"currentDir: {Environment.CurrentDirectory}"); var url = new Uri(PortableGit); using (var dir = url.DownloadAndSelfExtract("-y -gm2")) { //using (var dir = new TempCurDir(@"C:\Users\kingc\Downloads\PortableGit")) { using (var tempDir = new TempDir()) { var tempDirString = (string)tempDir; Console.WriteLine($"tempDir: {tempDir}"); using (var env = new TempCurDir("tools")) { // copy git-lfx.exe and libs to tools dir typeof(ImmutableDictionary).Assembly.Location.CopyToDir(); typeof(GitCmd).Assembly.Location.CopyToDir(); typeof(LfxCmd).Assembly.Location.CopyToDir(); typeof(Program).Assembly.Location.CopyToDir(); // add tools dir to path Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + env ); } using (var repoDir = new TempDir("repo")) { Git($"lfx init"); using (var gitDir = new TempDir("git")) { dir.Path.CopyDir("."); File.WriteAllLines(".gitattributes", new[] { $"* filter=lfx diff=lfx merge=lfx -text", $".gitattributes filter= diff= merge= text=auto", $".gitignore filter= diff= merge= text=auto", $"packages.config filter= diff= merge= text=auto", $"*.lfxconfig filter= diff= merge= text eol=lf" }); Git($"config -f .lfxconfig --add {LfxConfigFile.TypeId} {LfxPointerType.SelfExtractingArchive}"); Git($"config -f .lfxconfig --add {LfxConfigFile.UrlId} {PortableGit}"); Git($"config -f .lfxconfig --add {LfxConfigFile.ArgsId} \"{Args}\""); //Git($"lfx reset"); //Git($"lfx checkout"); } } } } }
public void Clone() { var args = Parse( minArgs: 2, maxArgs: 2 ); var repositoryUrl = args[0]; var target = args[1]; Git($"clone {repositoryUrl} {target} -n"); using (var dir = new TempCurDir(target)) { Lfx($"config --set"); Git($"checkout"); } }
public static void ManualTest() { Console.WriteLine($"currentDir: {Environment.CurrentDirectory}"); using (var tempDir = new TempDir()) { var tempDirString = (string)tempDir; Console.WriteLine($"tempDir: {tempDir}"); using (var env = new TempCurDir(ToolsDirName)) { // copy git-lfx.exe and libs to tools dir typeof(ImmutableDictionary).Assembly.Location.CopyToDir(); typeof(GitCmd).Assembly.Location.CopyToDir(); typeof(LfxCmd).Assembly.Location.CopyToDir(); typeof(Program).Assembly.Location.CopyToDir(); // add tools dir to path Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + env ); } using (var env = new TempCurDir(RemoteDirName)) { Git($"init --bare"); } using (var env = new TempCurDir(SourceDirName)) { Git($"init"); Git($"remote add origin ..\\{RemoteDirName}"); Git($"config --add filter.lfx.clean \"git-lfx clean %f\""); Git($"config --add filter.lfx.smudge \"git-lfx smudge --\""); Git($"config --get-regex .*lfx.*"); PackagesConfig.Save("packages.config"); using (var packages = new TempCurDir("packages")) { File.WriteAllText(GitAttributes, NugetGitAttributes); File.WriteAllText(GitIgnore, NugetGitIgnore); var gitConfig = GitConfig.Load(); Assert.AreEqual(env.ToString(), gitConfig.EnlistmentDirectory); Git($"config -f {LfxConfig} --add {LfxConfigFile.TypeId} {NugetType}"); Git($"config -f {LfxConfig} --add {LfxConfigFile.UrlId} {NugetUrl}"); Git($"config -f {LfxConfig} --add {LfxConfigFile.PatternId} {NugetRegex}"); Git($"config -f {LfxConfig} --add {LfxConfigFile.HintId} {NugetHint}"); Console.WriteLine($"{LfxConfig}: {Path.GetFullPath(LfxConfig)}:"); Console.WriteLine(File.ReadAllText(LfxConfig)); } Nuget($"restore -packagesDirectory packages"); Cmd($"where.exe", "git-lfx.exe"); Git($"add ."); Git($"commit -m \"Initial Commit\""); Git($"push -u origin master"); } Git($"clone remote target"); Console.WriteLine($"CurDir: {Environment.CurrentDirectory}"); } }
public void Init() { var nugetUrl = "https://dist.nuget.org/win-x86-commandline/v3.4.4/NuGet.exe"; var nugetHash = "c12d583dd1b5447ac905a334262e02718f641fca3877d0b6117fe44674072a27"; var nugetCount = 3957976L; var nugetPkgUrl = "http://nuget.org/api/v2/package/${id}/${ver}"; var nugetPkgPattern = "^((?<id>.*?)[.])(?=\\d)(?<ver>[^/]*)/(?<path>.*)$"; var nugetPkgHint = "${path}"; var args = Parse( maxArgs: 0, switchInfo: GitCmdSwitchInfo.Create( LfxCmdSwitches.Sample ) ); Git("init"); Lfx("config --set"); if (!args.IsSet(LfxCmdSwitches.Sample)) { return; } File.WriteAllText(".gitattributes", $"* text=auto"); using (var dls = new TempCurDir("dls")) { File.WriteAllLines(".gitattributes", new[] { $"* filter=lfx diff=lfx merge=lfx -text", $".gitattributes filter= diff= merge= text=auto", $".gitignore filter= diff= merge= text=auto", $"packages.config filter= diff= merge= text=auto", $"*.lfxconfig filter= diff= merge= text eol=lf" }); using (var packages = new TempCurDir("tools")) { Git($"config -f nuget.exe.lfxconfig --add lfx.type curl"); Git($"config -f nuget.exe.lfxconfig --add lfx.url {nugetUrl}"); File.WriteAllText("NuGet.exe", LfxPointer.Create( hash: LfxHash.Parse(nugetHash), count: nugetCount ).AddUrl(nugetUrl.ToUrl()).ToString()); } using (var packages = new TempCurDir("packages")) { File.WriteAllText(".gitignore", $"*.nupkg"); Git($"config -f .lfxconfig --add lfx.type archive"); Git($"config -f .lfxconfig --add lfx.url {nugetPkgUrl}"); Git($"config -f .lfxconfig --add lfx.pattern {nugetPkgPattern}"); Git($"config -f .lfxconfig --add lfx.hint {nugetPkgHint}"); new XElement("packages", new XElement("package", new XAttribute("id", "NUnit"), new XAttribute("version", "2.6.4") ) ).Save("packages.config"); } } }