private static string ShortSubject(GitStatus status) { string subject = status.MergeMessage?.Trim() ?? ""; string firstLine = subject.Split("\n".ToCharArray())[0]; return(firstLine); }
public GitStatus AddEntry(string path, GitStatus status) { if (string.IsNullOrEmpty(path) || path == ".") { this._status = status; return status; } if (_entries == null) _entries = new Dictionary<string, GitStatusSet>(); string entry; string subpath; var pos = path.IndexOf('/'); if (pos < 0) { entry = path; subpath = null; } else { entry = path.Substring(0, pos); subpath = path.Substring(pos + 1); } GitStatusSet subset; if (!_entries.TryGetValue(entry, out subset)) _entries[entry] = subset = new GitStatusSet(); status = subset.AddEntry(subpath, status); if (status == GitStatus.Added || status == GitStatus.Deleted || status == GitStatus.Modified) { this._status = GitStatus.Modified; } return this._status; }
public void TestFileCounts_UnstagedOnly() { string[] lines = @"## u/geevens/test...origin/u/geevens/test M second M third M fourth M fifth M sixth D tenth D eleventh D twelveth D thirteenth D fourteenth D fifteenth A seventeenth A eighteenth A nineteenth A twentith ".Split(new string[] { "\r\n" }, StringSplitOptions.None); GitStatus status = GitStatus.ParseLines(lines); Assert.AreEqual(@"u/geevens/test", status.Branch); Assert.AreEqual(GitStatus.UpToDateString, status.RemoteChanges); Assert.AreEqual(@"[ +0 ~0 -0 | +4 ~5 -6 ! ]", status.AllLocalChanges); Assert.AreEqual(@"[ +4 ~5 -6 ! ]", status.MimimalLocalChanges); }
public async Task <MRepository> UpdateAsync( MRepository mRepository, GitStatus status, IReadOnlyList <string> repoIds) { return(await Task.Run(async() => { MRepository repository = mRepository; string workingFolder = repository.WorkingFolder; try { await UpdateRepositoryAsync(repository, status, repoIds); } catch (Exception e) { Log.Exception(e, "Failed to update repository"); Log.Debug("Retry from scratch using a new repository ..."); repository = new MRepository() { WorkingFolder = workingFolder }; await UpdateRepositoryAsync(repository, status, repoIds); } return repository; })); }
public async Task ShouldRefreshAndReturnCombinedStatusAndLockInformation1() { var responseGitStatus = new GitStatus { LocalBranch = "master", Entries = new List <GitStatusEntry> { new GitStatusEntry("SomeLockedBinary.psd", null, "SomeLockedBinary.psd", GitFileStatus.Modified), new GitStatusEntry("subFolder/AnotherLockedBinary.psd", null, "subFolder/AnotherLockedBinary.psd", GitFileStatus.Modified), new GitStatusEntry("subFolder/UnLockedBinary.psd", null, "subFolder/UnLockedBinary.psd", GitFileStatus.Modified), } }; var responseGitLocks = new List <GitLock> { new GitLock("SomeLockedBinary.psd", "SomeLockedBinary.psd", "Someone", 1), new GitLock("SomeoneElsesBinary.psd", "SomeoneElsesBinary.psd", "SomeoneElse", 2), new GitLock("subFolder/AnotherLockedBinary.psd", "subFolder/AnotherLockedBinary.psd", "Someone", 3), }; var expectedGitStatus = new GitStatus { LocalBranch = "master", Entries = new List <GitStatusEntry> { new GitStatusEntry("SomeLockedBinary.psd", null, "SomeLockedBinary.psd", GitFileStatus.Modified), new GitStatusEntry("subFolder/AnotherLockedBinary.psd", null, "subFolder/AnotherLockedBinary.psd", GitFileStatus.Modified), new GitStatusEntry("subFolder/UnLockedBinary.psd", null, "subFolder/UnLockedBinary.psd", GitFileStatus.Modified), } }; var repositoryProcessRunner = CreateRepositoryProcessRunner(responseGitStatus, responseGitLocks); var repositoryManager = CreateRepositoryManager(repositoryProcessRunner); repositoryManager.Initialize(); repositoryManager.Start(); var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); repositoryManagerListener.AttachListener(repositoryManager); GitStatus?result = null; repositoryManager.OnStatusUpdated += s => { result = s; }; repositoryManager.Refresh(); await TaskEx.Delay(1000); repositoryManagerListener.Received(1).OnStatusUpdate(Args.GitStatus); result.HasValue.Should().BeTrue(); result.Value.AssertEqual(expectedGitStatus); repositoryManagerListener.DidNotReceive().OnActiveBranchChanged(Arg.Any <ConfigBranch?>()); repositoryManagerListener.DidNotReceive().OnActiveRemoteChanged(Arg.Any <ConfigRemote?>()); repositoryManagerListener.DidNotReceive().OnHeadChanged(); repositoryManagerListener.DidNotReceive().OnLocalBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteBranchListChanged(); }
private async Task <Repository> UpdateRepositoryAsync( Repository sourcerepository, GitStatus status, IReadOnlyList <string> branchIds) { using (await syncRootAsync.LockAsync()) { Log.Debug($"Updating repository"); MRepository mRepository = sourcerepository.MRepository; mRepository.IsCached = false; Timing t = new Timing(); await repositoryStructureService.UpdateAsync(mRepository, status, branchIds); t.Log("Updated mRepository"); if (mRepository.TimeToCreateFresh > MinCreateTimeBeforeCaching) { Log.Usage($"Caching repository ({t.Elapsed} ms)"); await cacheService.CacheAsync(mRepository); } Repository repository = ToRepository(mRepository); int branchesCount = repository.Branches.Count; int commitsCount = repository.Commits.Count; t.Log($"Updated repository {branchesCount} branches, {commitsCount} commits"); Log.Debug("Updated to repository"); return(repository); } }
public static void AssertEqual(this GitStatus gitStatus, GitStatus other) { gitStatus.Ahead.Should().Be(other.Ahead); gitStatus.Behind.Should().Be(other.Behind); gitStatus.LocalBranch.Should().Be(other.LocalBranch); gitStatus.RemoteBranch.Should().Be(other.RemoteBranch); gitStatus.Entries.AssertEqual(other.Entries); }
GitStatusData(NoSccStatus noSccStatus) { // TODO: Complete member initialization //this.noSccStatus = noSccStatus; _indexStatus = GitStatus.Normal; _workStatus = GitStatus.Normal; _kind = SvnNodeKind.Unknown; }
public static void AssertEqual(this GitStatus gitStatus, GitStatus other) { gitStatus.Ahead.Should().Be(other.Ahead, "Ahead should be equal"); gitStatus.Behind.Should().Be(other.Behind, "Behind should be equal"); gitStatus.LocalBranch.Should().Be(other.LocalBranch, "LocalBranch should be equal"); gitStatus.RemoteBranch.Should().Be(other.RemoteBranch, "RemoteBranch should be equal"); gitStatus.Entries.AssertEqual(other.Entries); }
public CreateRepositoryProcessRunnerOptions(Dictionary <GitConfigGetKey, string> getConfigResults = null, GitStatus gitStatusResults = new GitStatus(), List <GitLock> gitListLocksResults = null) { GitListLocksResults = gitListLocksResults; GitStatusResults = gitStatusResults; GitConfigGetResults = getConfigResults ?? new Dictionary <GitConfigGetKey, string>(); }
public async Task TestGetStatus() { await git.InitRepoAsync(); GitStatus status = await git.GetStatusAsync(); Assert.AreEqual(0, status.AllChanges); }
public void TaskStatusTest() { GitStatus t = new GitStatus(); t.BuildEngine = new DummyBuildEngine(); bool result = t.Execute(); Assert.IsTrue(result, "Execution failed"); }
static bool MaxModified(GitStatus status) { switch(status) { case GitStatus.None: case GitStatus.Normal: return true; } return false; }
public void TestBranchAhead() { string[] lines = @"## u/geevens/test...origin/u/geevens/test [ahead 1] ".Split(new string[] { "\r\n" }, StringSplitOptions.None); GitStatus status = GitStatus.ParseLines(lines); Assert.AreEqual(@"u/geevens/test", status.Branch); Assert.AreEqual("1 ahead", status.RemoteChanges); Assert.AreEqual(@"[ +0 ~0 -0 | +0 ~0 -0 ! ]", status.AllLocalChanges); Assert.AreEqual(@"", status.MimimalLocalChanges); }
public async Task <CommitDetails> GetAsync(CommitSha commitSha, GitStatus status) { if (commitSha == CommitSha.NoCommits) { return(new CommitDetails(new CommitFile[0], null)); } // Get fresh list of uncomitted files or try to get them from cach, otherwise get from repo if (commitSha == CommitSha.Uncommitted || !commitsFiles.TryGetValue(commitSha, out CommitDetails commitDetails)) { nextIdToGet = commitSha; await currentTask; if (nextIdToGet != commitSha) { // This commit id is no longer relevant return(new CommitDetails(new CommitFile[0], null)); } string message = (commitSha == CommitSha.Uncommitted || commitSha == CommitSha.NoCommits) ? null : (await gitCommitService.GetCommitMessageAsync(commitSha.Sha, CancellationToken.None)).Or(null); Task <R <IReadOnlyList <GitFile> > > commitsFilesForCommitTask = CommitsFilesForCommitTask(commitSha, status); GitConflicts conflicts = GitConflicts.None; if (commitSha == CommitSha.Uncommitted && status.HasConflicts) { conflicts = (await gitStatusService.GetConflictsAsync(CancellationToken.None)).Or(GitConflicts.None); } currentTask = commitsFilesForCommitTask; if ((await commitsFilesForCommitTask).HasValue(out var commitsFilesForCommit)) { var files = commitsFilesForCommit.Select(f => { GitConflictFile conflict = conflicts.Files.FirstOrDefault(cf => cf.FilePath == f.FilePath); return(new CommitFile(f, conflict)); }) .ToList(); commitDetails = new CommitDetails(files, message); // Cache the list of files commitsFiles[commitSha] = commitDetails; return(commitDetails); } Log.Error($"Failed to get files for {commitSha}"); return(new CommitDetails(new CommitFile[0], message)); } return(commitDetails); }
public void TestDeletedRemote() { string[] lines = @"## improve-status-parsing...origin/improve-status-parsing [gone] ".Split(new string[] { "\r\n" }, StringSplitOptions.None); GitStatus status = GitStatus.ParseLines(lines); Assert.AreEqual(@"improve-status-parsing", status.Branch); Assert.AreEqual("remote-gone", status.RemoteChanges); Assert.AreEqual(@"[ +0 ~0 -0 | +0 ~0 -0 ! ]", status.AllLocalChanges); Assert.AreEqual(@"", status.MimimalLocalChanges); }
public async Task ShouldDetectFileChanges() { await Initialize(TestRepoMasterCleanSynchronized); var managerAutoResetEvent = new RepositoryManagerAutoResetEvent(); var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); repositoryManagerListener.AttachListener(RepositoryManager, managerAutoResetEvent); var expected = new GitStatus { Behind = 1, LocalBranch = "master", RemoteBranch = "origin/master", Entries = new List <GitStatusEntry> { new GitStatusEntry("foobar.txt", TestRepoMasterCleanSynchronized.Combine("foobar.txt"), "foobar.txt", GitFileStatus.Untracked) } }; var result = new GitStatus(); RepositoryManager.OnRepositoryChanged += status => { result = status; }; Logger.Trace("Issuing Changes"); var foobarTxt = TestRepoMasterCleanSynchronized.Combine("foobar.txt"); foobarTxt.WriteAllText("foobar"); await TaskManager.Wait(); // give the fs watcher a bit of time to catch up await TaskEx.Delay(200); await TaskManager.Wait(); managerAutoResetEvent.OnRepositoryChanged.WaitOne(TimeSpan.FromSeconds(2)).Should().BeTrue(); Logger.Trace("Continue test"); repositoryManagerListener.Received().OnRepositoryChanged(Args.GitStatus); result.AssertEqual(expected); repositoryManagerListener.ReceivedWithAnyArgs().OnIsBusyChanged(Args.Bool); repositoryManagerListener.DidNotReceive().OnActiveBranchChanged(); repositoryManagerListener.DidNotReceive().OnActiveRemoteChanged(); repositoryManagerListener.DidNotReceive().OnHeadChanged(); repositoryManagerListener.DidNotReceive().OnLocalBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteOrTrackingChanged(); repositoryManagerListener.DidNotReceive().OnLocksUpdated(Args.EnumerableGitLock); }
static void Main(string[] args) { OldLogger.AnnounceStartStopActions = false; #if DEBUG OldLogger.AnnounceStartStopActions = true; #endif GitStatus status = GitStatus.Get(); string root = Environment.GetEnvironmentVariable("REPO_ROOT"); OldLogger.LogLine(String.Join(" ", new string[] { root, status.Branch, status.RemoteChanges, status.AllLocalChanges })); }
private async Task UpdateRepositoryAsync(GitStatus status, IReadOnlyList <string> repoIds) { if (Repository == null) { Log.Warn("No repository yet to update"); return; } Repository = await UpdateRepositoryAsync(Repository, status, repoIds); RepositoryUpdated?.Invoke(this, new RepositoryUpdatedEventArgs()); }
public void AddActiveBranches(IReadOnlyList <GitBranch> branches, MRepository repository) { GitStatus status = repository.Status; //GitBranch2 currentBranch = branches.GetCurrent(); foreach (GitBranch gitBranch in branches) { BranchName branchName = gitBranch.Name; if (branchName == BranchName.OriginHead || branchName == BranchName.Head) { continue; } MSubBranch subBranch = ToBranch(gitBranch, repository); repository.SubBranches[subBranch.SubBranchId] = subBranch; if (!status.OK && gitBranch.IsCurrent && !gitBranch.IsRemote) { // Setting virtual uncommitted commit as tip of the current branch subBranch.TipCommitId = repository.Uncommitted.Id; subBranch.TipCommit.SubBranchId = subBranch.SubBranchId; } } if (!branches.Any()) { MSubBranch subBranch = ToEmptyMasterBranch(repository); repository.SubBranches[subBranch.SubBranchId] = subBranch; if (!status.OK) { // Setting virtual uncommitted commit as tip of the current branch subBranch.TipCommitId = repository.Uncommitted.Id; subBranch.TipCommit.SubBranchId = subBranch.SubBranchId; } } if (branches.TryGetCurrent(out GitBranch currentBranch) && currentBranch.IsDetached) { MSubBranch subBranch = ToBranch(currentBranch, repository); repository.SubBranches[subBranch.SubBranchId] = subBranch; if (!status.OK) { // Setting virtual uncommitted commit as tip of the detached branch subBranch.TipCommitId = repository.Uncommitted.Id; subBranch.TipCommit.SubBranchId = subBranch.SubBranchId; } } }
public void TestMergeConflict() { string[] lines = @"## improve-status-parsing...origin/improve-status-parsing [ahead 5] M zune/client/xaml/music/UI/Music.UI.vcxproj UU zune/client/xaml/music/UI/Music.UI.vcxproj.filters M zune/client/xaml/music/UI/Services/NowPlayingViewManager.cpp ".Split(new string[] { "\r\n" }, StringSplitOptions.None); GitStatus status = GitStatus.ParseLines(lines); Assert.AreEqual(@"improve-status-parsing", status.Branch); Assert.AreEqual("5 ahead", status.RemoteChanges); Assert.AreEqual(@"[ +0 ~2 -0 #1 | +0 ~0 -0 #1 ! ]", status.AllLocalChanges); Assert.AreEqual(@"[ +0 ~2 -0 #1 | +0 ~0 -0 #1 ! ]", status.MimimalLocalChanges); }
public GitStatusData(GitStatusEventArgs status) { if (status == null) { throw new ArgumentNullException("status"); } _conflicted = status.Conflicted; _indexStatus = status.IndexStatus; _workStatus = status.WorkingDirectoryStatus; _ignored = status.Ignored; _conflicted = status.Conflicted; _kind = (SvnNodeKind)(int)status.NodeKind; _modified = status.IndexModified || status.WorkingDirectoryModified; }
public async Task ShouldDetectGitPull() { await Initialize(TestRepoMasterCleanSynchronized); var managerAutoResetEvent = new RepositoryManagerAutoResetEvent(); var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); repositoryManagerListener.AttachListener(RepositoryManager, managerAutoResetEvent); var expected = new GitStatus { LocalBranch = "master", RemoteBranch = "origin/master", Entries = new List <GitStatusEntry>() }; var result = new GitStatus(); RepositoryManager.OnRepositoryChanged += status => { result = status; }; Logger.Trace("Issuing Command"); await RepositoryManager.Pull("origin", "master").StartAsAsync(); await TaskManager.Wait(); managerAutoResetEvent.OnRepositoryChanged.WaitOne(TimeSpan.FromSeconds(7)).Should().BeTrue(); managerAutoResetEvent.OnActiveBranchChanged.WaitOne(TimeSpan.FromSeconds(7)).Should().BeTrue(); WaitForNotBusy(managerAutoResetEvent, 3); WaitForNotBusy(managerAutoResetEvent, 3); Logger.Trace("Continue test"); repositoryManagerListener.ReceivedWithAnyArgs().OnIsBusyChanged(Args.Bool); RepositoryManager.IsBusy.Should().BeFalse(); repositoryManagerListener.Received().OnRepositoryChanged(Args.GitStatus); result.AssertEqual(expected); repositoryManagerListener.Received(1).OnActiveBranchChanged(); repositoryManagerListener.DidNotReceive().OnActiveRemoteChanged(); repositoryManagerListener.DidNotReceive().OnHeadChanged(); repositoryManagerListener.DidNotReceive().OnLocalBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteOrTrackingChanged(); repositoryManagerListener.DidNotReceive().OnLocksUpdated(Args.EnumerableGitLock); }
public async Task ShouldDetectBranchChange() { await Initialize(TestRepoMasterCleanSynchronized); var managerAutoResetEvent = new RepositoryManagerAutoResetEvent(); var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); repositoryManagerListener.AttachListener(RepositoryManager, managerAutoResetEvent); var expected = new GitStatus { LocalBranch = "feature/document", RemoteBranch = "origin/feature/document", Entries = new List <GitStatusEntry>() }; var result = new GitStatus(); RepositoryManager.OnRepositoryChanged += status => { result = status; }; Logger.Trace("Issuing Command"); await RepositoryManager.SwitchBranch("feature/document").StartAsAsync(); await TaskManager.Wait(); // give the fs watcher a bit of time to catch up await TaskEx.Delay(100); await TaskManager.Wait(); managerAutoResetEvent.OnActiveBranchChanged.WaitOne(TimeSpan.FromSeconds(3)).Should().BeTrue(); managerAutoResetEvent.OnRepositoryChanged.WaitOne(TimeSpan.FromSeconds(3)).Should().BeTrue(); managerAutoResetEvent.OnHeadChanged.WaitOne(TimeSpan.FromSeconds(3)).Should().BeTrue(); Logger.Trace("Continue test"); repositoryManagerListener.Received().OnRepositoryChanged(Args.GitStatus); result.AssertEqual(expected); repositoryManagerListener.ReceivedWithAnyArgs().OnIsBusyChanged(Args.Bool); repositoryManagerListener.Received(1).OnActiveBranchChanged(); repositoryManagerListener.DidNotReceive().OnActiveRemoteChanged(); repositoryManagerListener.Received(1).OnHeadChanged(); repositoryManagerListener.DidNotReceive().OnLocalBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteOrTrackingChanged(); repositoryManagerListener.DidNotReceive().OnLocksUpdated(Args.EnumerableGitLock); }
public async Task <R <GitStatus> > GetStatusAsync(CancellationToken ct) { // Log.Debug($"Call stack: {new StackTrace(false)}"); R <CmdResult2> result = await gitCmdService.RunAsync(StatusArgs, ct); if (result.IsFaulted) { return(R.Error("Failed to get status", result.Exception)); } GitStatus status = ParseStatus(result.Value); Log.Info($"Status: {status} in {result.Value.WorkingDirectory}"); return(status); }
public async Task UpdateRepositoryAfterCommandAsync() { Task <GitStatus> statusTask = statusService.GetStatusAsync(); Task <IReadOnlyList <string> > repoIdsTask = statusService.GetRepoIdsAsync(); GitStatus status = await statusTask; IReadOnlyList <string> repoIds = await repoIdsTask; if (Repository.Status.IsSame(status) && Repository.MRepository.RepositoryIds.SequenceEqual(repoIds)) { Log.Debug("Repository has not changed after command"); return; } await UpdateRepositoryAsync(status, repoIds); }
private void AssertProcessOutput(IEnumerable <string> lines, GitStatus expected) { var gitObjectFactory = SubstituteFactory.CreateGitObjectFactory(TestRootPath); GitStatus?result = null; var outputProcessor = new GitStatusOutputProcessor(gitObjectFactory); outputProcessor.OnEntry += status => { result = status; }; foreach (var line in lines) { outputProcessor.LineReceived(line); } Assert.IsTrue(result.HasValue); result.Value.AssertEqual(expected); }
private async Task StartCheckStatusAsync(FileEventArgs fileEventArgs) { Log.Debug($"Checking status change at {fileEventArgs.DateTime} ..."); if (await IsStatusCheckStartedAsync()) { return; } Task <GitStatus> newStatusTask = GetFreshStatusAsync(); currentStatusTask = newStatusTask; GitStatus newStatus = await newStatusTask; TriggerStatusChanged(fileEventArgs, newStatus); }
public void TestFileCounts_StagedOnly() { string[] lines = @"## u/geevens/test...origin/u/geevens/test M first M second D seventh D eighth D nineth A sixteenth ".Split(new string[] { "\r\n" }, StringSplitOptions.None); GitStatus status = GitStatus.ParseLines(lines); Assert.AreEqual(@"u/geevens/test", status.Branch); Assert.AreEqual(GitStatus.UpToDateString, status.RemoteChanges); Assert.AreEqual(@"[ +1 ~2 -3 | +0 ~0 -0 ! ]", status.AllLocalChanges); Assert.AreEqual(@"[ +1 ~2 -3 ]", status.MimimalLocalChanges); }
public void TestRename() { string[] lines = @"## improve-status-parsing...origin/improve-status-parsing [ahead 5] M tools/FilterWriter.exe R WECTools/FilterWriter/FilterWriter.sln -> tools/FilterWriter/FilterWriter.sln ?? tools/FilterWriter/App.config ?? tools/FilterWriter/FilterWriter.csproj ?? tools/FilterWriter/Logger.cs ?? tools/FilterWriter/Node.cs ?? tools/FilterWriter/Program.cs ?? tools/FilterWriter/Properties/ ".Split(new string[] { "\r\n" }, StringSplitOptions.None); GitStatus status = GitStatus.ParseLines(lines); Assert.AreEqual(@"improve-status-parsing", status.Branch); Assert.AreEqual("5 ahead", status.RemoteChanges); Assert.AreEqual(@"[ +0 ~1 -0 | +6 ~1 -0 ! ]", status.AllLocalChanges); Assert.AreEqual(@"[ +0 ~1 -0 | +6 ~1 -0 ! ]", status.MimimalLocalChanges); }
public async Task ShouldDetectFileChanges() { await Initialize(TestRepoMasterCleanSynchronized); var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); repositoryManagerListener.AttachListener(RepositoryManager, repositoryManagerEvents); var expected = new GitStatus { Behind = 1, LocalBranch = "master", RemoteBranch = "origin/master", Entries = new List <GitStatusEntry> { new GitStatusEntry("foobar.txt", TestRepoMasterCleanSynchronized.Combine("foobar.txt"), "foobar.txt", GitFileStatus.Untracked) } }; var result = new GitStatus(); Environment.Repository.OnStatusUpdated += status => { result = status; }; var foobarTxt = TestRepoMasterCleanSynchronized.Combine("foobar.txt"); foobarTxt.WriteAllText("foobar"); await TaskManager.Wait(); RepositoryManager.WaitForEvents(); WaitForNotBusy(repositoryManagerEvents, 1); repositoryManagerListener.Received().OnStatusUpdate(Args.GitStatus); repositoryManagerListener.DidNotReceive().OnActiveBranchChanged(Arg.Any <ConfigBranch?>()); repositoryManagerListener.DidNotReceive().OnActiveRemoteChanged(Arg.Any <ConfigRemote?>()); repositoryManagerListener.DidNotReceive().OnHeadChanged(); repositoryManagerListener.DidNotReceive().OnLocalBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteBranchListChanged(); repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool); repositoryManagerListener.DidNotReceive().OnLocksUpdated(Args.EnumerableGitLock); result.AssertEqual(expected); }
private static void SetCurrentBranchAndCommit(MRepository repository, IReadOnlyList <GitBranch> branches) { GitStatus status = repository.Status; MBranch currentBranch = repository.Branches.Values.First(b => b.IsActive && b.IsCurrent); repository.CurrentBranchId = currentBranch.Id; branches.TryGetCurrent(out GitBranch current); repository.CurrentCommitId = status.OK ? current != null ? repository.Commit(new CommitId(current.TipSha.Sha)).Id : CommitId.NoCommits : CommitId.Uncommitted; if (currentBranch.TipCommit.IsVirtual && currentBranch.TipCommit.FirstParentId == repository.CurrentCommitId) { repository.CurrentCommitId = currentBranch.TipCommit.Id; } }
public VisualGitStatus(GitStatusEventArgs args) { if (args == null) throw new ArgumentNullException("args"); _nodeKind = args.NodeKind; _state = args.LocalContentStatus; _localCopied = args.LocalCopied; if (args.WorkingCopyInfo != null) { _lastChangeTime = args.WorkingCopyInfo.LastChangeTime; _lastChangeRevision = args.WorkingCopyInfo.LastChangeRevision; _lastChangeAuthor = args.WorkingCopyInfo.LastChangeAuthor; _revision = args.WorkingCopyInfo.Revision; } _treeConflict = args.TreeConflict; if(_treeConflict != null) _treeConflict.Detach(); }
public static Image GetImage(GitStatus status) { switch (status) { case GitStatus.Added: return GetImage(StatusIcon.Added); case GitStatus.Deleted: return GetImage(StatusIcon.Deleted); case GitStatus.Modified: return GetImage(StatusIcon.Modified); case GitStatus.OK: return GetImage(StatusIcon.OK); default: return null; } }
/// <summary> /// Create non-locked, non-copied item with status specified /// </summary> /// <param name="allStatuses"></param> private VisualGitStatus(GitStatus allStatuses) { _state = allStatuses; //_localLocked = false; //_localCopied = false; }