SchemaDownload.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace SharpGLTF
  5. {
  6. /// <summary>
  7. /// Utility class to download the gltf2 schema from github
  8. /// </summary>
  9. static class SchemaDownload
  10. {
  11. public static void Syncronize(string remoteUrl, string localDirectory)
  12. {
  13. if (LibGit2Sharp.Repository.Discover(localDirectory) == null)
  14. {
  15. Console.WriteLine($"Cloning {remoteUrl} can take several minutes; Please wait...");
  16. LibGit2Sharp.Repository.Clone(remoteUrl, localDirectory);
  17. Console.WriteLine($"... Clone Completed");
  18. return;
  19. }
  20. using (var repo = new LibGit2Sharp.Repository(localDirectory))
  21. {
  22. var options = new LibGit2Sharp.PullOptions
  23. {
  24. FetchOptions = new LibGit2Sharp.FetchOptions()
  25. };
  26. var r = LibGit2Sharp.Commands.Pull(repo, new LibGit2Sharp.Signature("Anonymous", "[email protected]", new DateTimeOffset(DateTime.Now)), options);
  27. Console.WriteLine($"{remoteUrl} is {r.Status}");
  28. }
  29. }
  30. }
  31. }