public void Commit_throws_an_exception_if_there_is_nothing_to_commit()
        {
            var repoPath = "commitex";

            using (new TempRepo(repoPath)) {
                var sut = new GitRepoProvider(repoPath);

                sut.Commit("initial", "test", "*****@*****.**"); // the initial commit is always working

                Assert.Throws <EmptyCommitException>(() => sut.Commit("failing", "test", "*****@*****.**"));
            }
        }
        public void Commit()
        {
            var repoPath = "commit";

            using (new TempRepo(repoPath))
            {
                var sut = new GitRepoProvider(repoPath);

                var status = sut.Status;
                Assert.Equal((0, 0, 0, 0), status);

                File.WriteAllText(repoPath + "/a.txt", "a");
                status = sut.Status;
                Assert.Equal((0, 1, 0, 0), status);

                sut.StageAllChanges();
                status = sut.Status;
                Assert.Equal((0, 1, 0, 0), status);

                var sha = sut.Commit("committing a.txt", "test", "*****@*****.**");
                _testOutputHelper.WriteLine($"Commit SHA: {sha}");

                status = sut.Status;
                Assert.Equal((0, 0, 0, 0), status);
            }
        }
Exemplo n.º 3
0
        void Commit_pending_changes()
        {
            _screenshots.Capture();

            var status = _git.Status;

            if (pending_changes_exist())
            {
                _git.StageAllChanges();
                var sha = _git.Commit(message(), "dp-record", "*****@*****.**");
                _log.Add(status, sha, _stopwatch.RunningTime);
                _stopwatch.Reset();
            }

            bool pending_changes_exist() => status.Modified + status.Added + status.Deleted + status.Other > 0;

            string message() => $"Auto-commit after {_stopwatch.RunningTime.TotalMinutes:F1}min";
        }