internal void Commit() { using (service.DisableRefresh()) { if (HasComments() && StageSelectedFiles(true)) { string errorMessage = null; try { ShowStatusMessage("Committing ..."); var result = tracker.Commit(Comments, false, chkSignOff.IsChecked == true); if (result.IsSha1) { ShowStatusMessage("Commit successfully. Commit Hash: " + result.Message); ClearUI(); } else { errorMessage = result.Message; } } catch (Exception ex) { errorMessage = ex.Message; } if (!String.IsNullOrEmpty(errorMessage)) { MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } } service.MarkDirty(false); }
public void AmendCommitTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("中文 1čtestč"); Assert.IsTrue(tracker.LastCommitMessage.StartsWith("中文 1čtestč")); File.WriteAllText(tempFile, "changed text"); tracker.StageFile(tempFile); tracker.Commit("new message", true); Assert.IsTrue(tracker.LastCommitMessage.StartsWith("new message")); }
internal void Commit() { var commitArgs = new Blinkbox.Events.OnCommitArgs { Message = this.Comments }; service.NoRefresh = true; if (HasComments() && StageSelectedFiles()) { try { ShowStatusMessage("Committing ..."); var id = tracker.Commit(Comments); ShowStatusMessage("Commit successfully. Commit Hash: " + id); ClearUI(); commitArgs.Success = true; commitArgs.Id = id; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); ShowStatusMessage(ex.Message); } } service.NoRefresh = false; //service.lastTimeRefresh = DateTime.Now; service.NodesGlyphsDirty = true; // force refresh Blinkbox.Events.BlinkboxSccHooks.TriggerCommit(this, commitArgs); }
public void GetFileContentTest() { var tempFolder = Environment.CurrentDirectory + "\\_gitscc_test_3"; var tempFile = Path.Combine(tempFolder, "test"); GitFileStatusTracker.Init(tempFolder); string[] lines = { "First line", "Second line", "Third line" }; File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test"); var fileContent = tracker.GetFileContent(tempFile); using (var binWriter = new BinaryWriter(File.Open(tempFile + ".bk", FileMode.Create))) { binWriter.Write(fileContent); } var newlines = File.ReadAllLines(tempFile + ".bk"); Assert.AreEqual(lines[0], newlines[0]); Assert.AreEqual(lines[1], newlines[1]); Assert.AreEqual(lines[2], newlines[2]); }
internal void Commit() { service.NoRefresh = true; if (HasComments() && StageSelectedFiles()) { try { ShowStatusMessage("Committing ..."); var id = tracker.Commit(Comments); ShowStatusMessage("Commit successfully. Commit Hash: " + id); ClearUI(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); ShowStatusMessage(ex.Message); } } service.NoRefresh = false; //service.lastTimeRefresh = DateTime.Now; service.NodesGlyphsDirty = true; // force refresh }
public void GetChangedFilesTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); Assert.AreEqual(GitFileStatus.New, tracker.ChangedFiles.ToList()[0].Status); tracker.StageFile(tempFile); Assert.AreEqual(GitFileStatus.Added, tracker.ChangedFiles.ToList()[0].Status); tracker.Commit("test"); Assert.AreEqual(0, tracker.ChangedFiles.Count()); File.WriteAllText(tempFile, "a"); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Modified, tracker.ChangedFiles.ToList()[0].Status); tracker.StageFile(tempFile); Assert.AreEqual(GitFileStatus.Staged, tracker.ChangedFiles.ToList()[0].Status); }
public void DiffFileTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test message"); File.WriteAllText(tempFile, "changed text"); var diff = tracker.DiffFile(tempFile); Console.WriteLine(diff); Assert.IsTrue(diff.StartsWith("@@ -1,3 +1 @@")); }
public void LastCommitMessageTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test message"); Assert.IsTrue(tracker.LastCommitMessage.StartsWith("test message")); }
public void GetFileStatusTest() { GitFileStatusTracker.Init(tempFolder); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); File.WriteAllLines(tempFile, lines); Assert.AreEqual(GitFileStatus.New, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile)); tracker.UnStageFile(tempFile); Assert.AreEqual(GitFileStatus.New, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile)); tracker.Commit("test commit"); Assert.AreEqual(GitFileStatus.Tracked, tracker.GetFileStatus(tempFile)); File.WriteAllText(tempFile, "changed text"); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); Assert.AreEqual(GitFileStatus.Staged, tracker.GetFileStatus(tempFile)); tracker.UnStageFile(tempFile); Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); File.Delete(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Deleted, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); Assert.AreEqual(GitFileStatus.Removed, tracker.GetFileStatus(tempFile)); tracker.UnStageFile(tempFile); Assert.AreEqual(GitFileStatus.Deleted, tracker.GetFileStatus(tempFile)); }
public void GetFileContentTestNegative() { GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); var fileContent = tracker.GetFileContent(tempFile + ".bad"); Assert.IsNull(fileContent); GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); tracker = new GitFileStatusTracker(tempFolder); fileContent = tracker.GetFileContent(tempFile + ".bad"); Assert.IsNull(fileContent); tracker.StageFile(tempFile); fileContent = tracker.GetFileContent(tempFile + ".bad"); Assert.IsNull(fileContent); tracker.Commit("test"); fileContent = tracker.GetFileContent(tempFile + ".bad"); Assert.IsNull(fileContent); }
public void GetFileContentTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test"); var fileContent = tracker.GetFileContent(tempFile); using (var binWriter = new BinaryWriter(File.Open(tempFile + ".bk", System.IO.FileMode.Create))) { binWriter.Write(fileContent); } var newlines = File.ReadAllLines(tempFile + ".bk"); Assert.AreEqual(lines[0], newlines[0]); Assert.AreEqual(lines[1], newlines[1]); Assert.AreEqual(lines[2], newlines[2]); }
public void CheckOutFileTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test"); File.WriteAllText(tempFile, "changed text"); tracker.CheckOutFile(tempFile); var newlines = File.ReadAllLines(tempFile); Assert.AreEqual(lines[0], newlines[0]); Assert.AreEqual(lines[1], newlines[1]); Assert.AreEqual(lines[2], newlines[2]); }
public void SaveFileFromRepositoryTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test"); tracker.SaveFileFromRepository(tempFile, tempFile + ".bk"); var newlines = File.ReadAllLines(tempFile + ".bk"); Assert.AreEqual(lines[0], newlines[0]); Assert.AreEqual(lines[1], newlines[1]); Assert.AreEqual(lines[2], newlines[2]); }
public void GetBranchTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); Assert.AreEqual("master", tracker.CurrentBranch); tracker.Commit("test message"); Assert.AreEqual("master", tracker.CurrentBranch); tempFile = tempFile.Replace("test", "TEST"); File.WriteAllText(tempFile, "changed text"); tracker.CheckOutBranch("dev", true); Assert.AreEqual("dev", tracker.CurrentBranch); }
public void FileNameCaseTest() { GitFileStatusTracker.Init(tempFolder); File.WriteAllLines(tempFile, lines); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test message"); Assert.IsTrue(tracker.LastCommitMessage.StartsWith("test message")); tempFile = tempFile.Replace("test", "TEST"); File.WriteAllText(tempFile, "changed text"); tracker.Refresh(); //This test fails all cases because status check uses ngit, never git.exe //Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); var file = tracker.ChangedFiles.First(); Assert.AreEqual(GitFileStatus.Modified, file.Status); }
public void GetFileStatusTest() { var tempFolder = Environment.CurrentDirectory + "\\_gitscc_test_2"; var tempFile = Path.Combine(tempFolder, "test"); GitFileStatusTracker.Init(tempFolder); GitFileStatusTracker tracker = new GitFileStatusTracker(tempFolder); string[] lines = { "First line", "Second line", "Third line" }; File.WriteAllLines(tempFile, lines); tracker.Refresh(); Assert.AreEqual(GitFileStatus.New, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile)); tracker.Commit("test"); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Trackered, tracker.GetFileStatus(tempFile)); File.WriteAllText(tempFile, "changed text"); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); File.Delete(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Missing, tracker.GetFileStatus(tempFile)); tracker.RemoveFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Removed, tracker.GetFileStatus(tempFile)); }