public void CanCommitWithOverrideAuthor() { var testPath = CloneTestRepository(_fixture.EmptyRepositoryPath); File.WriteAllLines(Path.Combine(testPath, "new.text"), new[] { "Hello", "World" }); var wrapper = new Git.GitWrapper(testPath); Assert.True(wrapper.AddAll().Result.Success); var commitResult = wrapper.Commit("First commit", "Alice Example <*****@*****.**>").Result; Assert.True(commitResult.Success); }
public void CanPullFromRemoteRepository() { var remotePath = CloneTestRepository(_fixture.PopulatedRepositoryPath); var localPath = CloneTestRepository(remotePath); File.WriteAllLines(Path.Combine(remotePath, "new.txt"), new [] { "Hello", "World" }); var remoteWrapper = new Git.GitWrapper(remotePath); var localWrapper = new Git.GitWrapper(localPath); Assert.True(remoteWrapper.AddAll().Result.Success); Assert.True(remoteWrapper.Commit("Added a file").Result.Success); Assert.True(localWrapper.Pull().Result.Success); Assert.True(File.Exists(Path.Combine(localPath, "new.txt"))); }
public void StatusReportsNewFile() { var testPath = CloneTestRepository(_fixture.PopulatedRepositoryPath); var testFile = Path.Combine(testPath, "new.txt"); File.WriteAllLines(testFile, new [] { "Hello", "World" }); var wrapper = new Git.GitWrapper(testPath); Assert.True(wrapper.AddAll().Result.Success); var statusResult = wrapper.Status().Result; Assert.True(statusResult.Success); Assert.Single(statusResult.NewFiles); Assert.Equal("new.txt", statusResult.NewFiles[0]); }
public void StatusReportsDeletedFile() { var testPath = CloneTestRepository(_fixture.PopulatedRepositoryPath); var testFile = Path.Combine(testPath, "test.txt"); File.Delete(testFile); var wrapper = new Git.GitWrapper(testPath); Assert.True(wrapper.AddAll().Result.Success); var statusResult = wrapper.Status().Result; Assert.True(statusResult.Success); Assert.Single(statusResult.DeletedFiles); Assert.Equal("test.txt", statusResult.DeletedFiles[0]); }
public void CanFetchFromRemoteRepository() { var remotePath = CloneTestRepository(_fixture.PopulatedRepositoryPath); var localPath = CloneTestRepository(remotePath); File.WriteAllLines(Path.Combine(remotePath, "new.txt"), new [] { "Hello", "World" }); var remoteWrapper = new Git.GitWrapper(remotePath); var localWrapper = new Git.GitWrapper(localPath); Assert.True(remoteWrapper.AddAll().Result.Success); Assert.True(remoteWrapper.Commit("Added a file").Result.Success); var fetchResult = localWrapper.Fetch().Result; Assert.True(fetchResult.Success); Assert.Contains("master", fetchResult.UpdatedBranches); }
public void StatusReportsModifiedFile() { var testPath = CloneTestRepository(_fixture.PopulatedRepositoryPath); var testFile = Path.Combine(testPath, "test.txt"); var lines = File.ReadAllLines(testFile).ToList(); lines.RemoveAt(1); File.WriteAllLines(testFile, lines); var wrapper = new Git.GitWrapper(testPath); Assert.True(wrapper.AddAll().Result.Success); var statusResult = wrapper.Status().Result; Assert.True(statusResult.Success); Assert.Single(statusResult.ModifiedFiles); Assert.Equal("test.txt", statusResult.ModifiedFiles[0]); }
public void CanPushToRemoteRepository() { var remotePath = CloneTestRepository(_fixture.PopulatedRepositoryPath, true); var localPath = CloneTestRepository(remotePath); var localWrapper = new Git.GitWrapper(localPath); var checkoutResult = localWrapper.SetBranch("master").Result; Assert.True(checkoutResult.Success); File.WriteAllLines(Path.Combine(localPath, "new.txt"), new[] { "Hello", "World" }); Assert.True(localWrapper.AddAll().Result.Success); Assert.True(localWrapper.Commit("Added a file").Result.Success); var pushResult = localWrapper.Push().Result; Assert.True(pushResult.Success); // We can't test for the file existing in the remote repo because it is cloned as a bare repo. // So instead make a second clone and check that this gets the file that was pushed from the first one var newLocalPath = CloneTestRepository(remotePath); Assert.True(File.Exists(Path.Combine(newLocalPath, "new.txt"))); }
public void LocalDiffReportsNewFileAdded() { var testPath = CloneTestRepository(_fixture.PopulatedRepositoryPath); var newFile = Path.Combine(testPath, "new.txt"); var lines = new[] { "Hello", "World" }; File.WriteAllLines(newFile, lines); var wrapper = new Git.GitWrapper(testPath); var addResult = wrapper.AddAll().Result; Assert.True(addResult.Success); var diffResult = wrapper.DiffHead().Result; Assert.NotNull(diffResult); Assert.NotNull(diffResult.CommandResult); Assert.True(diffResult.Success); Assert.Single(diffResult.FileDiffs); Assert.Equal(2, diffResult.FileDiffs[0].Inserted.Count); Assert.Empty(diffResult.FileDiffs[0].Deleted); Assert.Equal("Hello", diffResult.FileDiffs[0].Inserted[0]); Assert.Equal("World", diffResult.FileDiffs[0].Inserted[1]); }
public void LocalDiffReportsFileDeleted() { var testPath = CloneTestRepository(_fixture.PopulatedRepositoryPath); var testFile = Path.Combine(testPath, "test.txt"); File.Delete(testFile); var wrapper = new Git.GitWrapper(testPath); var addResult = wrapper.AddAll().Result; Assert.True(addResult.Success); var diffResult = wrapper.DiffHead().Result; Assert.NotNull(diffResult); Assert.NotNull(diffResult.CommandResult); Assert.True(diffResult.Success); Assert.Single(diffResult.FileDiffs); Assert.Equal(3, diffResult.FileDiffs[0].Deleted.Count); Assert.Empty(diffResult.FileDiffs[0].Inserted); Assert.Equal("Line 1", diffResult.FileDiffs[0].Deleted[0]); Assert.Equal("Line 2", diffResult.FileDiffs[0].Deleted[1]); Assert.Equal("Line 3", diffResult.FileDiffs[0].Deleted[2]); }