Ejemplo n.º 1
0
        public static void SyncronizeGitRepository(string remoteUrl, string localDirectoryPath)
        {
            if (!System.IO.Path.IsPathRooted(localDirectoryPath))
            {
                throw new ArgumentException(nameof(localDirectoryPath));
            }

            lock (_DownloadMutex)
            {
                if (LibGit2Sharp.Repository.Discover(localDirectoryPath) == null)
                {
                    Console.WriteLine($"Cloning {remoteUrl} can take several minutes; Please wait...");

                    LibGit2Sharp.Repository.Clone(remoteUrl, localDirectoryPath);

                    Console.WriteLine($"... Clone Completed");

                    return;
                }

                using (var repo = new LibGit2Sharp.Repository(localDirectoryPath))
                {
                    var options = new LibGit2Sharp.PullOptions
                    {
                        FetchOptions = new LibGit2Sharp.FetchOptions()
                    };

                    var r = LibGit2Sharp.Commands.Pull(repo, new LibGit2Sharp.Signature("Anonymous", "*****@*****.**", new DateTimeOffset(DateTime.Now)), options);

                    Console.WriteLine($"{remoteUrl} is {r.Status}");
                }
            }
        }
Ejemplo n.º 2
0
        public static void SyncronizeGitRepository(string remoteUrl, string localDirectory)
        {
            if (LibGit2Sharp.Repository.Discover(localDirectory) == null)
            {
                NUnit.Framework.TestContext.Progress.WriteLine($"Cloning {remoteUrl} can take several minutes; Please wait...");

                LibGit2Sharp.Repository.Clone(remoteUrl, localDirectory);

                NUnit.Framework.TestContext.Progress.WriteLine($"... Clone Completed");

                return;
            }

            using (var repo = new LibGit2Sharp.Repository(localDirectory))
            {
                var options = new LibGit2Sharp.PullOptions
                {
                    FetchOptions = new LibGit2Sharp.FetchOptions()
                };

                var r = LibGit2Sharp.Commands.Pull(repo, new LibGit2Sharp.Signature("Anonymous", "*****@*****.**", new DateTimeOffset(DateTime.Now)), options);

                NUnit.Framework.TestContext.Progress.WriteLine($"{remoteUrl} is {r.Status}");
            }
        }