public void GetCurrentCheckout_should_query_git_and_return_null_if_response_is_not_sha(string msg) { using (_executable.StageOutput($"rev-parse HEAD", msg, 0)) { _gitModule.GetCurrentCheckout().Should().BeNull(); } }
private static GitRevision GetCurrentRevision(GitModule aModule, RevisionGrid RevisionGrid, List <GitHead> currentTags, List <GitHead> currentLocalBranches, List <GitHead> currentRemoteBranches, List <GitHead> currentBranches, GitRevision currentRevision, string option) { if (option.StartsWith("{c") && currentRevision == null) { IList <GitHead> heads; if (RevisionGrid == null) { heads = new List <GitHead>(); string currentRevisionGuid = aModule.GetCurrentCheckout(); foreach (GitHead head in aModule.GetHeads(true, true)) { if (head.Guid == currentRevisionGuid) { heads.Add(head); } } } else { currentRevision = RevisionGrid.GetCurrentRevision(); heads = currentRevision.Heads; } foreach (GitHead head in heads) { if (head.IsTag) { currentTags.Add(head); } else if (head.IsHead || head.IsRemote) { currentBranches.Add(head); if (head.IsRemote) { currentRemoteBranches.Add(head); } else { currentLocalBranches.Add(head); } } } } return(currentRevision); }
private static GitRevision GetCurrentRevision( GitModule module, [CanBeNull] RevisionGridControl revisionGrid, List <IGitRef> currentTags, List <IGitRef> currentLocalBranches, List <IGitRef> currentRemoteBranches, List <IGitRef> currentBranches, [CanBeNull] GitRevision currentRevision) { if (currentRevision == null) { IEnumerable <IGitRef> refs; if (revisionGrid == null) { var currentRevisionGuid = module.GetCurrentCheckout(); refs = module.GetRefs(true, true).Where(gitRef => gitRef.ObjectId == currentRevisionGuid).ToList(); } else { currentRevision = revisionGrid.GetCurrentRevision(); refs = currentRevision.Refs; } foreach (var gitRef in refs) { if (gitRef.IsTag) { currentTags.Add(gitRef); } else if (gitRef.IsHead || gitRef.IsRemote) { currentBranches.Add(gitRef); if (gitRef.IsRemote) { currentRemoteBranches.Add(gitRef); } else { currentLocalBranches.Add(gitRef); } } } } return(currentRevision); }
private static GitRevision GetCurrentRevision(GitModule module, RevisionGrid revisionGrid, List <IGitRef> currentTags, List <IGitRef> currentLocalBranches, List <IGitRef> currentRemoteBranches, List <IGitRef> currentBranches, GitRevision currentRevision) { if (currentRevision == null) { IList <IGitRef> refs; if (revisionGrid == null) { string currentRevisionGuid = module.GetCurrentCheckout(); refs = module.GetRefs(true, true).Where(gitRef => gitRef.Guid == currentRevisionGuid).ToList(); } else { currentRevision = revisionGrid.GetCurrentRevision(); refs = currentRevision.Refs; } foreach (IGitRef gitRef in refs) { if (gitRef.IsTag) { currentTags.Add(gitRef); } else if (gitRef.IsHead || gitRef.IsRemote) { currentBranches.Add(gitRef); if (gitRef.IsRemote) { currentRemoteBranches.Add(gitRef); } else { currentLocalBranches.Add(gitRef); } } } } return(currentRevision); }