public void StashWontPopIfConflictedOnUnStagedFile() { File.WriteAllText(@"testgit\file1", "This is a test"); GitStashWrapper git = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T); GitStashOptions options = new GitStashOptions { Untracked = true }; options.Message = "Testing"; IGitStashResults results = git.SaveStash(options); Assert.IsTrue(results.Success); Assert.IsTrue(git.Stashes.Count == 1); Assert.IsFalse(File.Exists("file1")); using (StreamWriter sw = File.AppendText(@"testgit\file1")) { sw.WriteLine("This is another test"); } results = git.PopStash(new GitStashOptions(), 0); Assert.IsFalse(results.Success); Assert.IsTrue(git.Stashes.Count == 1); string txt = File.ReadAllText(@"testgit\file1"); Assert.IsTrue(txt == "Commit this!This is another test\r\n"); }
public void Bug_57_CreateStashWithNewUntrackedChangeDoesntThrowException() { FileStream fs = File.Create(@"testgit\file2"); fs.Close(); GitStashWrapper git = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T); GitStashOptions options = new GitStashOptions { Untracked = false, All = false, Ignored = false, Index = false, KeepIndex = false, Message = "bug_57" }; IGitStashResults results = git.SaveStash(options); Assert.IsFalse(results.Success); Assert.IsTrue(git.Stashes.Count == 0); Assert.IsTrue(File.Exists(@"testgit\file2")); }
public void TestStash() { FileStream fs = File.Create(@"testgit\file2"); fs.Close(); GitStashWrapper git = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T); IEnumerable <IGitStash> stashes = git.Stashes; GitStashOptions options = new GitStashOptions { Untracked = true }; options.Message = "Testing"; IGitStashResults results = git.SaveStash(options); Assert.IsFalse(File.Exists("file2")); Assert.IsTrue(results.Success); Assert.IsTrue(git.Stashes.Count == 1); }
private void OnClickCreateStashButton() { IGitStashSaveOptions options = new GitStashOptions { All = StashAll, Ignored = StashIgnored, KeepIndex = StashKeepIndex, Untracked = StashUntracked, Message = NewStashMessage }; IGitStashResults results = wrapper.SaveStash(options); if (!string.IsNullOrEmpty(results.Message)) { page.ShowNotification(results.Message, NotificationType.Information); } if (results.Success) { NewStashMessage = ""; OnPropertyChanged("Stashes"); OnPropertyChanged("NewStashMessage"); OnPropertyChanged("CreateStashButtonCommand"); } else { } }
public void TestDeletethrowsExceptionWithInvalidIndex() { FileStream fs = File.Create(@"testgit\file2"); fs.Close(); GitStashWrapper git = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T); GitStashOptions options = new GitStashOptions { Untracked = true }; options.Message = "Testing"; IGitStashResults results = git.SaveStash(options); Assert.IsTrue(results.Success); Assert.IsTrue(git.Stashes.Count == 1); Assert.IsFalse(File.Exists("file2")); results = git.DropStash(new GitStashOptions(), 2); Assert.IsFalse(results.Success); Assert.IsTrue(git.Stashes.Count == 1); Assert.IsFalse(File.Exists(@"testgit\file2")); }
public void TestStashesReturnsTheProperIndex() { FileStream fs = File.Create(@"testgit\file2"); fs.Close(); GitStashWrapper git = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T); GitStashOptions options = new GitStashOptions { Untracked = true }; options.Message = "one"; IGitStashResults results = git.SaveStash(options); Assert.IsTrue(results.Success); Assert.IsTrue(git.Stashes.Count == 1); Assert.IsFalse(File.Exists("file2")); fs = File.Create(@"testgit\file2"); fs.Close(); options.Message = "two"; results = git.SaveStash(options); Assert.IsTrue(results.Success); Assert.IsTrue(git.Stashes.Count == 2); Assert.IsFalse(File.Exists("file2")); IGitStash recent = git.Stashes[0]; IGitStash older = git.Stashes[1]; Assert.IsTrue(recent.Index == 0); Assert.IsTrue(recent.Message == "two"); Assert.IsTrue(older.Index == 1); Assert.IsTrue(older.Message == "one"); }