Пример #1
0
        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);
        }
Пример #2
0
        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")));
        }
Пример #3
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);
        }
Пример #4
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")));
        }