예제 #1
0
        private static GitRevision GetCurrentRevision(
            [NotNull] IVsrModule module, [CanBeNull] IScriptHostControl scriptHostControl, List <IGitRef> currentTags, List <IGitRef> currentLocalBranches,
            List <IGitRef> currentRemoteBranches, List <IGitRef> currentBranches)
        {
            GitRevision           currentRevision;
            IEnumerable <IGitRef> refs;

            if (scriptHostControl == null)
            {
                var currentRevisionGuid = module.GetCurrentCheckout();
                currentRevision = currentRevisionGuid == null ? null : new GitRevision(currentRevisionGuid);
                refs            = module.GetRefs(true, true).Where(gitRef => gitRef.ObjectId == currentRevisionGuid);
            }
            else
            {
                currentRevision = scriptHostControl.GetCurrentRevision();
                refs            = currentRevision?.Refs ?? Array.Empty <IGitRef>();
            }

            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);
        }