public void push()
        {
            //Create a clone
            var repoPath3 = "repo3".tempDir();

            repoPath3.delete_Folder();
            Assert.IsFalse(repoPath3.dirExists());
            Assert.IsFalse(repoPath3.isGitRepository());
            var nGit3 = repoPath1.git_Clone(repoPath3);

            var filesInRepo1 = nGit1.files();
            var filesInRepo3 = nGit3.files();

            Assert.AreEqual(1, filesInRepo1.size());
            Assert.AreEqual(1, filesInRepo3.size());
            var repo1_File = nGit1.files_FullPath().first();
            var repo3_File = nGit3.files_FullPath().first();

            Assert.IsTrue(repo1_File.fileExists());
            Assert.IsTrue(repo3_File.fileExists());

            Assert.IsNotNull(nGit3);
            Assert.IsTrue(repoPath3.dirExists());
            Assert.IsTrue(repoPath3.isGitRepository());
            Assert.AreEqual(repo3_File.fileContents(), repo1_File.fileContents());

            //change a file in the clone (repoPath3) and push it into the origin (repoPath1)

            var newContent = 10.randomLetters();

            newContent.saveAs(repo3_File);
            Assert.AreNotEqual("", nGit3.status());
            nGit3.add_and_Commit_using_Status();
            Assert.AreEqual("", nGit3.status());
            Assert.AreEqual(1, nGit1.commits().size());
            Assert.AreEqual(2, nGit3.commits().size());
            Assert.AreNotEqual(repo3_File.fileContents(), repo1_File.fileContents());
            Assert.AreEqual(1, nGit1.commits().size());
            Assert.AreEqual("", nGit1.status());

            var result_Push = nGit3.push();

            Assert.IsTrue(result_Push);
            Assert.AreEqual(2, nGit1.commits().size());
            Assert.AreNotEqual("", nGit1.status());
            Assert.AreNotEqual(repo3_File.fileContents(), repo1_File.fileContents());          // local file on disk has not been changed until a checkout happens


            nGit3.delete_Repository_And_Files();
            Assert.IsFalse(repoPath3.dirExists());


            //Null value handling
            Assert.IsFalse((null as API_NGit).push(null));
            Assert.IsFalse(nGit3.push(null));
        }
        public static List <string> files(this API_NGit nGit, string commitId)
        {
            var repoFiles = new List <string>();

            nGit.files(commitId, (treeWalk) => repoFiles.Add(treeWalk.PathString));
            return(repoFiles);
        }
        public void fetch()
        {
            var commits_BeforeFetch = nGit2.commits();
            var head_BeforeFetch    = nGit2.head();
            //repoPath2.startProcess();

            var fetchResult1       = nGit2.fetch(repoPath1, "master");
            var commits_AfterFetch = nGit2.commits();
            var head_AfterFetch    = nGit2.head();

            Assert.IsEmpty(commits_BeforeFetch);
            Assert.IsNotEmpty(commits_AfterFetch);
            Assert.IsNull(head_BeforeFetch);
            Assert.IsNotNull(head_AfterFetch);     // I would expect this to be true

            Assert.IsNull(nGit2.Last_Exception);
            Assert.IsNotNull(nGit2.Last_FetchResult);
            Assert.IsTrue(fetchResult1);

            var filesInRepo1 = nGit1.files();
            var filesInRepo2 = nGit2.files();

            Assert.AreEqual(1, filesInRepo1.size());
            Assert.AreEqual(1, filesInRepo2.size());
            var fullPathInRepo1 = nGit1.file_FullPath(filesInRepo1.first());
            var fullPathInRepo2 = nGit2.file_FullPath(filesInRepo2.first());

            Assert.IsTrue(fullPathInRepo1.fileExists());
            Assert.IsFalse(fullPathInRepo2.fileExists());

            //test Error handling

            var fetchResult2 = nGit2.fetch(repoPath1, "master_", "master");

            Assert.IsNotNull(nGit2.Last_Exception);
            Assert.IsNull(nGit2.Last_FetchResult);
            Assert.IsFalse(fetchResult2);
            Assert.AreEqual(nGit2.Last_Exception.Message, "Remote does not have refs/heads/master_ available for fetch.");

            var fetchResult3 = nGit2.fetch();

            Assert.IsNotNull(nGit2.Last_Exception);
            Assert.IsNull(nGit2.Last_FetchResult);
            Assert.IsFalse(fetchResult2);
            Assert.AreEqual(nGit2.Last_Exception.Message, "Invalid remote: origin");
        }
 public static List <string> files_HEAD(this API_NGit nGit)
 {
     return(nGit.files(nGit.head()));
 }
 public static List <string> files_FullPath(this API_NGit nGit)
 {
     return((from file in nGit.files()
             select nGit.file_FullPath(file)).toList());
 }