internal void Test(Action <TemporaryRepository> preSteps, Action <TemporaryRepository> triggerSteps)
        {
            using (var tempFolder = new TemporaryFolder())
            {
                var tempRepository = new TemporaryRepository(tempFolder);

                tempRepository.RunCommand("init");
                tempRepository.TouchFileAndCommit();

                preSteps(tempRepository);

                // Let everything stablize
                Thread.Sleep(RepositoryWatcher.DampeningIntervalInMilliseconds * 10);

                var triggered = false;
                var watcher   = new RepositoryWatcher(tempFolder.Path);
                watcher.ChangeDetected += (sender, args) => { triggered = true; };

                triggerSteps(tempRepository);

                Thread.Sleep(RepositoryWatcher.DampeningIntervalInMilliseconds * 10);

                Assert.IsTrue(triggered);
            }
        }
Beispiel #2
0
 private void RepoOnChangeEnd(RepositoryWatcher repositoryWatcher, GitRepository gitRepository)
 {
     Console.WriteLine("Changed End.");
     UpdateMenu();
     gitRepository.AddAll();
     gitRepository.Commit();
 }
Beispiel #3
0
        private static string WatcherStatus(RepositoryWatcher watcher)
        {
            var text = "Paused";

            if (!watcher.IsWatching)
            {
                text = watcher.IsChanging
                      ? "Commiting Changes"
                      : string.Format("Last Updated: {0}", watcher.LastChange.ToString("h:mm:ss tt"));
            }

            return(text);
        }
Beispiel #4
0
        public bool AddRepository(string workingDirectory)
        {
            if (RepositoryWatchers.Any(x => x.Repository.WorkingDirectory == workingDirectory))
            {
                return(false);
            }

            var gitRepository = new GitRepository(workingDirectory);
            var watcher       = new RepositoryWatcher(gitRepository);

            Console.WriteLine("Starting {0} ({1})", gitRepository.Name, gitRepository.WorkingDirectory);

            watcher.ChangeStart += RepoOnChangeStart;
            watcher.ChangeEnd   += RepoOnChangeEnd;
            watcher.IsWatching   = true;

            RepositoryWatchers.Add(watcher);

            return(true);
        }
Beispiel #5
0
 private void RepoOnChangeStart(RepositoryWatcher repositoryWatcher, GitRepository gitRepository)
 {
     Console.WriteLine("Changed Start.");
     UpdateMenu();
 }