Esempio n. 1
0
 public void StaticGetLastFileCommit() {
     var dir = FileSystemHelper.ResetTemporaryDirectory();
     var gh = new GitHelper { DirectoryName = dir };
     Directory.CreateDirectory(Path.Combine(dir, "a"));
     var file = Path.Combine(dir, "a", "x");
     File.WriteAllText(file, "zzz");
     var file2 = Path.Combine(dir, "a", "y");
     File.WriteAllText(file2, "zzz2");
     gh.Init();
     gh.CommitAllChanges();
     var fstCommit = gh.GetCommitId();
     File.WriteAllText(file2, "zzz3");
     gh.CommitAllChanges();
     var secCommit = gh.GetCommitId();
     Assert.AreEqual(fstCommit, GitHelper.GetLastCommit(file).Hash);
     Assert.AreEqual(secCommit, GitHelper.GetLastCommit(file2).Hash);
 }
Esempio n. 2
0
 public void StaticGetCommit() {
     var dir = FileSystemHelper.ResetTemporaryDirectory();
     Directory.CreateDirectory(Path.Combine(dir, "a"));
     var file = Path.Combine(dir, "a", "x");
     File.WriteAllText(file,"zzz");
     Assert.Null(GitHelper.GetCommit(file));
     var gh = new GitHelper {DirectoryName = dir};
     gh.Init();
     var hash = gh.CommitAllChanges();
     Assert.AreEqual(hash, GitHelper.GetCommit(file).Hash);
 }
Esempio n. 3
0
		public void CanGetChangedList()
		{
			var githelper = new GitHelper { DirectoryName = dirname };
			githelper.Connect();
			githelper.WriteFile("x","1");
			githelper.WriteFile("y","1");
			var changed = githelper.GetChangedFilesList();
			Assert.AreEqual(2,changed.Length);
			Assert.True(changed.Any(_=>_.FileName=="x"));
			Assert.True(changed.Any(_=>_.FileName=="y"));
			var ver1 = githelper.CommitAllChanges("1");
			changed = githelper.GetChangedFilesList();
			Assert.AreEqual(0, changed.Length);
			changed = githelper.GetChangedFilesList(toref:"HEAD");
			Assert.AreEqual(2, changed.Length);
			var ver2 = githelper.WriteAndCommit("x", "2", "2");
			changed = githelper.GetChangedFilesList(toref: "HEAD");
			Assert.AreEqual(1, changed.Length);
			var ver3 = githelper.WriteAndCommit("y", "2", "3");
			changed = githelper.GetChangedFilesList(toref: "HEAD");
			Assert.AreEqual(1, changed.Length);
			changed = githelper.GetChangedFilesList(fromref:ver1,toref: "HEAD");
			Assert.AreEqual(2, changed.Length);
		}