private async void menuUndo_Click(object sender, RoutedEventArgs e) { const string deleteMsg = @" Note: Undo file changes will restore the file(s) from the last commit."; var filesToUndo = new List <string>(); GetSelectedFiles(fileName => filesToUndo.Add(fileName)); string title = (filesToUndo.Count == 1) ? "Undo File Changes" : "Undo Files Changes for " + filesToUndo.Count + " Files?"; string message = (filesToUndo.Count == 1) ? "Are you sure you want to undo changes to file: " + Path.GetFileName(filesToUndo.First()) + deleteMsg : String.Format("Are you sure you want to undo changes to {0} files", filesToUndo.Count) + deleteMsg; if (MessageBox.Show(message, title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { this.toolWindow.Service.NoRefresh = true; await Task.Run(() => { foreach (var fileName in filesToUndo) { tracker.CheckOutFile(fileName); } }); this.toolWindow.Service.NoRefresh = false; await this.toolWindow.Service.RefreshToolWindows(); } }
public void CheckOutFileTest() { GitRepository.Init(tempFolder); File.WriteAllLines(tempFilePath, lines); GitRepository tracker = new GitRepository(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test"); File.WriteAllText(tempFilePath, "changed text"); tracker.CheckOutFile(tempFile); var newlines = File.ReadAllLines(tempFilePath); Assert.AreEqual(lines[0], newlines[0]); Assert.AreEqual(lines[1], newlines[1]); Assert.AreEqual(lines[2], newlines[2]); }