Exemple #1
0
        private async Task GetSubmoduleStatusAsync(SubmoduleInfo info, CancellationToken cancelToken)
        {
            await TaskScheduler.Default;

            cancelToken.ThrowIfCancellationRequested();

            var submodule     = new GitModule(info.Path);
            var supermodule   = submodule.SuperprojectModule;
            var submoduleName = submodule.GetCurrentSubmoduleLocalPath();

            info.Status = null;

            if (string.IsNullOrEmpty(submoduleName) || supermodule == null)
            {
                return;
            }

            var submoduleStatus = GitCommandHelpers.GetCurrentSubmoduleChanges(supermodule, submoduleName);

            if (submoduleStatus != null && submoduleStatus.Commit != submoduleStatus.OldCommit)
            {
                submoduleStatus.CheckSubmoduleStatus(submoduleStatus.GetSubmodule(supermodule));
            }

            if (submoduleStatus != null)
            {
                info.Status  = submoduleStatus.Status;
                info.IsDirty = submoduleStatus.IsDirty;
                info.Text   += submoduleStatus.AddedAndRemovedString();
            }
        }
        private async Task GetSubmoduleStatusAsync(SubmoduleInfo info, CancellationToken cancelToken)
        {
            if (!AppSettings.ShowSubmoduleStatus)
            {
                return;
            }

            await TaskScheduler.Default;

            cancelToken.ThrowIfCancellationRequested();

            var submodule     = new GitModule(info.Path);
            var supermodule   = submodule.SuperprojectModule;
            var submoduleName = submodule.GetCurrentSubmoduleLocalPath();

            if (string.IsNullOrEmpty(submoduleName) || supermodule == null)
            {
                return;
            }

            info.Detailed = new AsyncLazy <DetailedSubmoduleInfo>(async() =>
            {
                await TaskScheduler.Default;
                cancelToken.ThrowIfCancellationRequested();

                var submoduleStatus = GitCommandHelpers.GetCurrentSubmoduleChanges(supermodule, submoduleName);
                if (submoduleStatus != null && submoduleStatus.Commit != submoduleStatus.OldCommit)
                {
                    submoduleStatus.CheckSubmoduleStatus(submoduleStatus.GetSubmodule(supermodule));
                }

                if (submoduleStatus != null)
                {
                    return(new DetailedSubmoduleInfo()
                    {
                        Status = submoduleStatus.Status,
                        IsDirty = submoduleStatus.IsDirty,
                        AddedAndRemovedText = submoduleStatus.AddedAndRemovedString()
                    });
                }

                return(null);
            }, ThreadHelper.JoinableTaskFactory);
        }