private async Task SetSubmoduleDataAsync(bool updateStatus, SubmoduleInfoResult result, GitModule module, CancellationToken cancelToken, string noBranchText, IGitModule topProject) { await TaskScheduler.Default; var submodules = topProject.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName).ToArray(); if (submodules.Any()) { string localPath = module.WorkingDir.Substring(topProject.WorkingDir.Length); localPath = PathUtil.GetDirectoryName(localPath.ToPosixPath()); foreach (var submodule in submodules) { cancelToken.ThrowIfCancellationRequested(); string path = topProject.GetSubmoduleFullPath(submodule); string name = submodule + GetBranchNameSuffix(path, noBranchText); bool bold = false; if (submodule == localPath) { result.CurrentSubmoduleName = module.GetCurrentSubmoduleLocalPath(); bold = true; } var smi = new SubmoduleInfo { Text = name, Path = path, Bold = bold }; result.SuperSubmodules.Add(smi); GetSubmoduleStatus(updateStatus, smi, cancelToken); } } }
private void SetSubmoduleData(GitModule currentModule, SubmoduleInfoResult result, string noBranchText, IGitModule topProject) { var submodules = topProject.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName).ToArray(); if (submodules.Any()) { string localPath = result.Module.WorkingDir.Substring(topProject.WorkingDir.Length); localPath = Path.GetDirectoryName(localPath).ToPosixPath(); foreach (var submodule in submodules) { string path = topProject.GetSubmoduleFullPath(submodule); string name = submodule + GetBranchNameSuffix(path, noBranchText); bool bold = false; if (submodule == localPath) { result.CurrentSubmoduleName = currentModule.GetCurrentSubmoduleLocalPath(); bold = true; } var smi = new SubmoduleInfo { Text = name, Path = path, Bold = bold }; result.SuperSubmodules.Add(smi); } } }
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 void SetSubmoduleData(GitModule currentModule, SubmoduleInfoResult result, string noBranchText, IGitModule topProject) { var submodules = topProject.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName).ToArray(); if (!submodules.Any()) { return; } var superWorkDir = currentModule.SuperprojectModule?.WorkingDir; var currentWorkDir = currentModule.WorkingDir; var localPath = currentWorkDir.Substring(topProject.WorkingDir.Length); if (string.IsNullOrWhiteSpace(localPath)) { localPath = "."; } localPath = Path.GetDirectoryName(localPath).ToPosixPath(); foreach (var submodule in submodules) { string path = topProject.GetSubmoduleFullPath(submodule); string name = submodule + GetBranchNameSuffix(path, noBranchText); bool bold = false; if (submodule == localPath) { result.CurrentSubmoduleName = currentModule.GetCurrentSubmoduleLocalPath(); bold = true; } var smi = new SubmoduleInfo { Text = name, Path = path, Bold = bold }; result.AllSubmodules.Add(smi); if (path == superWorkDir) { result.SuperProject = smi; } if (path != currentWorkDir && path.StartsWith(currentWorkDir)) { result.OurSubmodules.Add(smi); } } }
private void GetRepositorySubmodulesStructure(SubmoduleInfoResult result, string noBranchText) { foreach (var submodule in result.Module.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName)) { var name = submodule; string path = result.Module.GetSubmoduleFullPath(submodule); if (AppSettings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path)) { name = name + " " + GetModuleBranch(path, noBranchText); } var smi = new SubmoduleInfo { Text = name, Path = path }; result.OurSubmodules.Add(smi); } }
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); }
private void GetRepositorySubmodulesStatus(SubmoduleInfoResult result, IGitModule module, CancellationToken cancelToken, string noBranchText) { foreach (var submodule in module.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName)) { cancelToken.ThrowIfCancellationRequested(); var name = submodule; string path = module.GetSubmoduleFullPath(submodule); if (AppSettings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path)) { name = name + " " + GetModuleBranch(path, noBranchText); } var smi = new SubmoduleInfo { Text = name, Path = path }; result.OurSubmodules.Add(smi); GetSubmoduleStatusAsync(smi, cancelToken).FileAndForget(); } }
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); }
private async Task GetRepositorySubmodulesStatusAsync(SubmoduleInfoResult result, IGitModule module, CancellationToken cancelToken, string noBranchText) { List <Task> tasks = new List <Task>(); foreach (var submodule in module.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName)) { cancelToken.ThrowIfCancellationRequested(); var name = submodule; string path = module.GetSubmoduleFullPath(submodule); if (AppSettings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path)) { name = name + " " + GetModuleBranch(path, noBranchText); } var smi = new SubmoduleInfo { Text = name, Path = path }; result.OurSubmodules.Add(smi); tasks.Add(GetSubmoduleStatusAsync(smi, cancelToken)); } await Task.WhenAll(tasks); }
private async Task GetSuperProjectRepositorySubmodulesStatusAsync(SubmoduleInfoResult result, GitModule module, CancellationToken cancelToken, string noBranchText) { if (module.SuperprojectModule == null) { return; } string name, path; GitModule supersuperproject = FindTopProjectModule(module.SuperprojectModule); if (module.SuperprojectModule.WorkingDir != supersuperproject.WorkingDir) { name = Path.GetFileName(Path.GetDirectoryName(supersuperproject.WorkingDir)); path = supersuperproject.WorkingDir; if (AppSettings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path)) { name = name + " " + GetModuleBranch(path, noBranchText); } result.TopProject = new SubmoduleInfo { Text = name, Path = supersuperproject.WorkingDir }; await GetSubmoduleStatusAsync(result.TopProject, cancelToken); } if (module.SuperprojectModule.WorkingDir != supersuperproject.WorkingDir) { var localPath = module.SuperprojectModule.WorkingDir.Substring(supersuperproject.WorkingDir.Length); localPath = PathUtil.GetDirectoryName(localPath.ToPosixPath()); name = localPath; } else { name = Path.GetFileName(Path.GetDirectoryName(supersuperproject.WorkingDir)); } path = module.SuperprojectModule.WorkingDir; if (AppSettings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path)) { name = name + " " + GetModuleBranch(path, noBranchText); } result.SuperProject = new SubmoduleInfo { Text = name, Path = module.SuperprojectModule.WorkingDir }; await GetSubmoduleStatusAsync(result.SuperProject, cancelToken); var submodules = supersuperproject.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName).ToArray(); if (submodules.Any()) { string localPath = module.WorkingDir.Substring(supersuperproject.WorkingDir.Length); localPath = PathUtil.GetDirectoryName(localPath.ToPosixPath()); List <Task> subTasks = new List <Task>(); foreach (var submodule in submodules) { cancelToken.ThrowIfCancellationRequested(); name = submodule; path = supersuperproject.GetSubmoduleFullPath(submodule); if (AppSettings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path)) { name = name + " " + GetModuleBranch(path, noBranchText); } bool bold = false; if (submodule == localPath) { result.CurrentSubmoduleName = module.GetCurrentSubmoduleLocalPath(); bold = true; } var smi = new SubmoduleInfo { Text = name, Path = path, Bold = bold }; result.SuperSubmodules.Add(smi); subTasks.Add(GetSubmoduleStatusAsync(smi, cancelToken)); } await Task.WhenAll(subTasks); } }