/// <summary>
        /// Get the detailed submodule status for 'submoduleName' and below
        /// </summary>
        /// <param name="superModule">Module to compare to</param>
        /// <param name="submoduleName">Name of the submodule</param>
        /// <param name="cancelToken">Cancelation token</param>
        /// <returns>the task</returns>
        private async Task GetSubmoduleDetailedStatusAsync(GitModule superModule, string submoduleName, CancellationToken cancelToken)
        {
            if (superModule == null || string.IsNullOrWhiteSpace(submoduleName))
            {
                return;
            }

            var path = superModule.GetSubmoduleFullPath(submoduleName);

            if (!_submoduleInfos.ContainsKey(path) || _submoduleInfos[path] == null)
            {
                return;
            }

            var info = _submoduleInfos[path];

            cancelToken.ThrowIfCancellationRequested();

            var submoduleStatus = await GitCommandHelpers.GetCurrentSubmoduleChangesAsync(superModule, submoduleName, noLocks : true)
                                  .ConfigureAwait(false);

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

            // If no changes, set info.Detailed set to null
            info.Detailed = submoduleStatus == null ?
                            null :
                            new DetailedSubmoduleInfo
            {
                Status              = submoduleStatus.Status,
                IsDirty             = submoduleStatus.IsDirty,
                AddedAndRemovedText = submoduleStatus.AddedAndRemovedString()
            };

            if (submoduleStatus != null)
            {
                // If any module is changed, top module is dirty
                // This sets the status but will not clear until a full refresh
                SetModuleAsDirtyUpwards(superModule.GetTopModule());
            }

            // Recursively update submodules
            var module = new GitModule(path);

            if (submoduleStatus != null && submoduleStatus.IsDirty)
            {
                await GetSubmoduleDetailedStatusAsync(module, cancelToken);

                return;
            }

            // no changes to submodules
            foreach (var name in module.GetSubmodulesLocalPaths(false))
            {
                SetSubmoduleEmptyDetailedStatus(module, name);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the detailed submodule status for 'submoduleName' and below
        /// </summary>
        /// <param name="superModule">Module to compare to</param>
        /// <param name="submoduleName">Name of the submodule</param>
        /// <param name="cancelToken">Cancelation token</param>
        /// <returns>the task</returns>
        private async Task GetSubmoduleDetailedStatusAsync(GitModule superModule, string submoduleName, CancellationToken cancelToken)
        {
            if (superModule == null || submoduleName.IsNullOrWhiteSpace())
            {
                return;
            }

            var path = superModule.GetSubmoduleFullPath(submoduleName);

            if (!_submoduleInfos.ContainsKey(path) || _submoduleInfos[path] == null)
            {
                return;
            }

            var info = _submoduleInfos[path];

            cancelToken.ThrowIfCancellationRequested();

            var submoduleStatus = await GitCommandHelpers.GetCurrentSubmoduleChangesAsync(superModule, submoduleName, noLocks : true)
                                  .ConfigureAwait(false);

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

            info.Detailed = submoduleStatus == null ?
                            null :
                            new DetailedSubmoduleInfo()
            {
                Status              = submoduleStatus.Status,
                IsDirty             = submoduleStatus.IsDirty,
                AddedAndRemovedText = submoduleStatus.AddedAndRemovedString()
            };

            if (submoduleStatus != null)
            {
                SetTopModuleAsDirty(superModule.GetTopModule().WorkingDir);
            }

            // Recursively update submodules
            var module = new GitModule(path);

            await GetSubmoduleDetailedStatusAsync(module, cancelToken);
        }
Exemplo n.º 3
0
        private void GetSubmoduleStatus(bool updateStatus, SubmoduleInfo info, CancellationToken cancelToken)
        {
            if (!updateStatus)
            {
                return;
            }

            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() =>
            {
                cancelToken.ThrowIfCancellationRequested();

                var submoduleStatus = await GitCommandHelpers.GetCurrentSubmoduleChangesAsync(supermodule, submoduleName, noLocks: true).ConfigureAwait(false);
                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);
        }