本文整理汇总了C#中GitCommands.GitModule.GetCurrentSubmoduleLocalPath方法的典型用法代码示例。如果您正苦于以下问题:C# GitModule.GetCurrentSubmoduleLocalPath方法的具体用法?C# GitModule.GetCurrentSubmoduleLocalPath怎么用?C# GitModule.GetCurrentSubmoduleLocalPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitCommands.GitModule
的用法示例。
在下文中一共展示了GitModule.GetCurrentSubmoduleLocalPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateSubmodulesList
private void UpdateSubmodulesList()
{
_previousUpdateTime = DateTime.Now;
// Cancel any previous async activities:
_submodulesStatusCTS.Cancel();
_submodulesStatusCTS.Dispose();
_submodulesStatusCTS = new CancellationTokenSource();
RemoveSubmoduleButtons();
toolStripButtonLevelUp.DropDownItems.Add(_loading.Text);
// Start gathering new submodule information asynchronously. This makes a significant difference in UI
// responsiveness if there are numerous submodules (e.g. > 100).
var cancelToken = _submodulesStatusCTS.Token;
string thisModuleDir = Module.WorkingDir;
// First task: Gather list of submodules on a background thread.
var updateTask = Task.Factory.StartNew(() =>
{
// Don't access Module directly because it's not thread-safe. Use a thread-local version:
GitModule threadModule = new GitModule(thisModuleDir);
SubmoduleInfoResult result = new SubmoduleInfoResult();
// Add all submodules inside the current repository:
foreach (var submodule in threadModule.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName))
{
cancelToken.ThrowIfCancellationRequested();
var name = submodule;
string path = threadModule.GetSubmoduleFullPath(submodule);
if (Settings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path))
name = name + " " + GetModuleBranch(path);
var smi = new SubmoduleInfo { Text = name, Path = path };
result.OurSubmodules.Add(smi);
GetSubmoduleStatusAsync(smi, cancelToken);
}
if (threadModule.SuperprojectModule != null)
{
GitModule supersuperproject = threadModule.FindTopProjectModule();
if (threadModule.SuperprojectModule.WorkingDir != supersuperproject.WorkingDir)
{
var name = Path.GetFileName(Path.GetDirectoryName(supersuperproject.WorkingDir));
string path = supersuperproject.WorkingDir;
if (Settings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path))
name = name + " " + GetModuleBranch(path);
result.TopProject = new SubmoduleInfo { Text = name, Path = supersuperproject.WorkingDir };
GetSubmoduleStatusAsync(result.TopProject, cancelToken);
}
{
string name;
GitModule parentModule = threadModule.SuperprojectModule;
string localpath = "";
if (threadModule.SuperprojectModule.WorkingDir != supersuperproject.WorkingDir)
{
parentModule = supersuperproject;
localpath = threadModule.SuperprojectModule.WorkingDir.Substring(supersuperproject.WorkingDir.Length);
localpath = PathUtil.GetDirectoryName(localpath.ToPosixPath());
name = localpath;
}
else
name = Path.GetFileName(Path.GetDirectoryName(supersuperproject.WorkingDir));
string path = threadModule.SuperprojectModule.WorkingDir;
if (Settings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path))
name = name + " " + GetModuleBranch(path);
result.Superproject = new SubmoduleInfo { Text = name, Path = threadModule.SuperprojectModule.WorkingDir };
GetSubmoduleStatusAsync(result.Superproject, cancelToken);
}
var submodules = supersuperproject.GetSubmodulesLocalPaths().OrderBy(submoduleName => submoduleName);
if (submodules.Any())
{
string localpath = threadModule.WorkingDir.Substring(supersuperproject.WorkingDir.Length);
localpath = PathUtil.GetDirectoryName(localpath.ToPosixPath());
foreach (var submodule in submodules)
{
cancelToken.ThrowIfCancellationRequested();
var name = submodule;
string path = supersuperproject.GetSubmoduleFullPath(submodule);
if (Settings.DashboardShowCurrentBranch && !GitModule.IsBareRepository(path))
name = name + " " + GetModuleBranch(path);
bool bold = false;
if (submodule == localpath)
{
result.CurrentSubmoduleName = threadModule.GetCurrentSubmoduleLocalPath();
bold = true;
}
var smi = new SubmoduleInfo { Text = name, Path = path, Bold = bold };
result.SuperSubmodules.Add(smi);
GetSubmoduleStatusAsync(smi, cancelToken);
}
}
}
return result;
}, cancelToken);
//.........这里部分代码省略.........
示例2: GetSubmoduleStatusAsync
private static void GetSubmoduleStatusAsync(SubmoduleInfo info, CancellationToken cancelToken)
{
Task.Factory.StartNew(() =>
{
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();
}
}, cancelToken, TaskCreationOptions.AttachedToParent, TaskScheduler.Default);
}