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); } }
public void Staging_changes_and_checking_status() { var repoPath = "stagingchanges"; 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); File.Delete(repoPath + "/a.txt"); status = sut.Status; Assert.Equal((0, 0, 0, 0), status); File.WriteAllText(repoPath + "/ab.txt", "ab"); status = sut.Status; Assert.Equal((0, 1, 0, 0), status); sut.StageAllChanges(); status = sut.Status; Assert.Equal((0, 1, 0, 0), status); File.Delete(repoPath + "/ab.txt"); status = sut.Status; Assert.Equal((0, 0, 1, 0), status); } }
public void Find_repo_root() { using (var sut = new GitRepoProvider(".")) { var result = sut.RepoPath; Assert.True(Directory.Exists(Path.Combine(result, ".git"))); } }
internal App(IConsoleLog log, GitRepoProvider git, IScreenshotProvider screenshots, Func <int, IRepeater> repeaterFactory) { _log = log; _git = git; _repeaterFactory = repeaterFactory; _stopwatch = new Stopwatch(); _screenshots = screenshots; }
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", "*****@*****.**")); } }
static void Main(string[] args) { var cli = new CLI(args); var git = new GitRepoProvider("."); var screenshots = cli.TakeScreenshots ? new ScreenshotProvider(Path.Combine(git.RepoPath, "Screenshots")) : (IScreenshotProvider) new NoScreenshotsProvider(); var app = new App( new ConsoleLog(), git, screenshots); app.Run(cli); }
public App(IConsoleLog log, GitRepoProvider git, IScreenshotProvider screenshots) : this(log, git, screenshots, intervalSeconds => new Repeater(intervalSeconds)) { }