本文整理汇总了C#中GitCommands.GitModule.ValidWorkingDir方法的典型用法代码示例。如果您正苦于以下问题:C# GitModule.ValidWorkingDir方法的具体用法?C# GitModule.ValidWorkingDir怎么用?C# GitModule.ValidWorkingDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitCommands.GitModule
的用法示例。
在下文中一共展示了GitModule.ValidWorkingDir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetGitHosterForModule
public static IRepositoryHostPlugin TryGetGitHosterForModule(GitModule aModule)
{
if (!aModule.ValidWorkingDir())
return null;
return GitHosters.FirstOrDefault(gitHoster => gitHoster.GitModuleIsRelevantToMe(aModule));
}
示例2: GetOldCommitData
public CommitData GetOldCommitData(GitModule submodule)
{
if (submodule == null || !submodule.ValidWorkingDir())
return null;
string error = "";
return CommitData.GetCommitData(submodule, OldCommit, ref error);
}
示例3: CheckIsCommitNewer
public void CheckIsCommitNewer(GitModule submodule)
{
if (submodule == null || !submodule.ValidWorkingDir())
return;
string baseCommit = submodule.GetMergeBase(Commit, OldCommit);
IsCommitNewer = baseCommit == OldCommit;
}
示例4: FetchData
private void FetchData()
{
Loading.Visible = true;
CommitCount.Text = "";
var dict = new Dictionary<string, HashSet<string>>();
var items = CommitCounter.GroupAllCommitsByContributor().Item1;
if (cbIncludeSubmodules.Checked)
{
IList<string> submodules = Settings.Module.GetSubmodulesNames();
GitModule submodule = new GitModule();
foreach (var submoduleName in submodules)
{
submodule.WorkingDir = Settings.Module.WorkingDir + submoduleName + Settings.PathSeparator.ToString();
if (submodule.ValidWorkingDir())
{
var submoduleItems = CommitCounter.GroupAllCommitsByContributor(submodule).Item1;
foreach (var keyValuePair in submoduleItems)
{
if (!dict.ContainsKey(keyValuePair.Key))
dict.Add(keyValuePair.Key, new HashSet<string>());
dict[keyValuePair.Key].Add(submodule.SubmoduleName);
if (items.ContainsKey(keyValuePair.Key))
items[keyValuePair.Key] += keyValuePair.Value;
else
items.Add(keyValuePair.Key, keyValuePair.Value);
}
}
}
}
var sortedItems = from pair in items
orderby pair.Value descending
select pair;
foreach (var keyValuePair in sortedItems)
{
string submodulesList = "";
if (dict.ContainsKey(keyValuePair.Key))
{
var sub = dict[keyValuePair.Key];
if (sub.Count == 1)
{
foreach (var item in dict[keyValuePair.Key])
submodulesList = " [" + item + "]";
}
else
submodulesList = " [" + sub.Count.ToString() + " submodules]";
}
CommitCount.Text += string.Format("{0,6} - {1}{2}\r\n", keyValuePair.Value, keyValuePair.Key, submodulesList);
}
Loading.Visible = false;
}
示例5: BranchDropDown
private void BranchDropDown(object sender, EventArgs e)
{
GitModule module = new GitModule(Directory.Text);
Branch.DisplayMember = "Name";
IList<GitHead> heads;
if (module.ValidWorkingDir())
heads = module.GetHeads(false);
else
heads = new List<GitHead>();
heads.Insert(0, GitHead.NoHead(module));
Branch.DataSource = heads;
}
示例6: OpenPath
private void OpenPath(string path)
{
GitModule module = new GitModule(path);
if (!module.ValidWorkingDir())
{
DialogResult dialogResult = MessageBox.Show(this, directoryIsNotAValidRepository.Text,
directoryIsNotAValidRepositoryCaption.Text, MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
if (dialogResult == DialogResult.Cancel)
{
return;
}
if (dialogResult == DialogResult.Yes)
{
Repositories.RepositoryHistory.RemoveRecentRepository(path);
Refresh();
return;
}
}
Repositories.AddMostRecentRepository(module.WorkingDir);
OnModuleChanged(module);
}
示例7: groupLayoutPanel_DragDrop
private void groupLayoutPanel_DragDrop(object sender, DragEventArgs e)
{
var fileNameArray = e.Data.GetData(DataFormats.FileDrop) as string[];
if (fileNameArray != null)
{
if (fileNameArray.Length != 1)
return;
string dir = fileNameArray[0];
if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir))
{
GitModule module = new GitModule(dir);
if (!module.ValidWorkingDir())
{
DialogResult dialogResult = MessageBox.Show(this, directoryIsNotAValidRepositoryOpenIt.Text,
directoryIsNotAValidRepositoryCaption.Text, MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
if (dialogResult == DialogResult.No)
return;
}
Repositories.AddMostRecentRepository(module.WorkingDir);
OnModuleChanged(module);
}
return;
}
var text = e.Data.GetData(DataFormats.UnicodeText) as string;
if (!string.IsNullOrEmpty(text))
{
var lines = text.Split('\n');
if (lines.Length != 1)
return;
string url = lines[0];
if (!string.IsNullOrEmpty(url))
{
UICommands.StartCloneDialog(this, url, false, OnModuleChanged);
}
}
}
示例8: IsSubmodulesIntialized
private bool IsSubmodulesIntialized()
{
// Fast submodules check
var submodules = Settings.Module.GetSubmodulesNames();
GitModule submodule = new GitModule();
foreach (var submoduleName in submodules)
{
submodule.WorkingDir = Settings.Module.WorkingDir + submoduleName + Settings.PathSeparator.ToString();
if (!submodule.ValidWorkingDir())
return false;
}
return true;
}
示例9: ChangeWorkingDir
private void ChangeWorkingDir(string path)
{
GitModule module = new GitModule(path);
if (!module.ValidWorkingDir())
{
DialogResult dialogResult = MessageBox.Show(this, directoryIsNotAValidRepository.Text,
directoryIsNotAValidRepositoryCaption.Text, MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
if (dialogResult == DialogResult.Yes)
{
Repositories.RepositoryHistory.RemoveRecentRepository(path);
return;
}
else if (dialogResult == DialogResult.Cancel)
return;
}
SetGitModule(module);
}
示例10: IsSubmodulesIntialized
private bool IsSubmodulesIntialized()
{
// Fast submodules check
var submodules = Settings.Module.GetSubmodulesLocalPaths();
GitModule submodule = new GitModule();
foreach (var submoduleName in submodules)
{
submodule.WorkingDir = Settings.Module.GetSubmoduleFullPath(submoduleName);
if (!submodule.ValidWorkingDir())
return false;
}
return true;
}
示例11: ProcessSubmodulePatch
public static string ProcessSubmodulePatch(string text)
{
StringBuilder sb = new StringBuilder();
using (StringReader reader = new StringReader(text))
{
string line;
string module = "";
while ((line = reader.ReadLine()) != null)
{
if (line.StartsWith("+++ "))
{
module = line.Substring("+++ ".Length);
var list = module.Split(new char[] { ' ' }, 2);
module = list.Length > 0 ? list[0] : "";
if (module.Length > 2 && module[1] == '/')
{
module = module.Substring(2);
break;
}
}
}
sb.AppendLine("Submodule " + module + " Change");
string fromHash = null;
string toHash = null;
bool dirtyFlag = false;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains("Subproject"))
{
sb.AppendLine();
char c = line[0];
const string commit = "commit ";
string hash = "";
int pos = line.IndexOf(commit);
if (pos >= 0)
hash = line.Substring(pos + commit.Length);
bool bdirty = hash.EndsWith("-dirty");
dirtyFlag |= bdirty;
hash = hash.Replace("-dirty", "");
string dirty = !bdirty ? "" : " (dirty)";
if (c == '-')
{
fromHash = hash;
sb.AppendLine("From:\t" + hash + dirty);
}
else if (c == '+')
{
toHash = hash;
sb.AppendLine("To:\t\t" + hash + dirty);
}
string path = Settings.Module.GetSubmoduleFullPath(module);
GitModule gitmodule = new GitModule(path);
if (gitmodule.ValidWorkingDir())
{
string error = "";
CommitData commitData = CommitData.GetCommitData(gitmodule, hash, ref error);
if (commitData != null)
{
sb.AppendLine("\t\t\t\t\t" + GitCommandHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.CommitDate.UtcDateTime) + commitData.CommitDate.LocalDateTime.ToString(" (ddd MMM dd HH':'mm':'ss yyyy)"));
var delim = new char[] { '\n', '\r' };
var lines = commitData.Body.Trim(delim).Split(new string[] { "\r\n" }, 0);
foreach (var curline in lines)
sb.AppendLine("\t\t" + curline);
}
if (fromHash != null && toHash != null)
{
if (dirtyFlag)
{
string status = gitmodule.GetStatusText(false);
if (!String.IsNullOrEmpty(status))
{
sb.AppendLine("\nStatus:");
sb.Append(status);
}
}
string diffs = gitmodule.GetDiffFilesText(fromHash, toHash);
if (!String.IsNullOrEmpty(diffs))
{
sb.AppendLine("\nDifferences:");
sb.Append(diffs);
}
}
}
else
sb.AppendLine();
}
}
}
return sb.ToString();
}
示例12: ProcessSubmodulePatch
private string ProcessSubmodulePatch(string text)
{
StringBuilder sb = new StringBuilder();
using (StringReader reader = new StringReader(text))
{
string line = reader.ReadLine();
const string gitstr = "--git ";
string module = "";
int pos = line.IndexOf(gitstr);
if (pos >= 0)
{
module = line.Substring(pos + gitstr.Length);
var list = module.Split(new char[] {' '},2);
module = list.Length > 0 ? list[0] : "";
if (module.StartsWith("a/"))
module = module.Substring(2);
}
sb.AppendLine("Submodule " + module + " Change");
while ((line = reader.ReadLine()) != null)
{
if (line.Contains("Subproject"))
{
sb.AppendLine();
char c = line[0];
const string commit = "commit ";
string hash = "";
pos = line.IndexOf(commit);
if (pos >= 0)
hash = line.Substring(pos + commit.Length);
bool bdirty = hash.EndsWith("-dirty");
hash = hash.Replace("-dirty", "");
string dirty = !bdirty ? "" : " (dirty)";
if (c == '-')
sb.AppendLine("From:\t" + hash + dirty);
else if (c == '+')
sb.AppendLine("To:\t\t" + hash + dirty);
string path = Settings.Module.GetSubmoduleFullPath(module);
GitModule gitmodule = new GitModule(path);
if (gitmodule.ValidWorkingDir())
{
string error = "";
CommitData commitData = CommitData.GetCommitData(gitmodule, hash, ref error);
if (commitData != null)
{
sb.AppendLine("\t\t\t\t\t" + GitCommandHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.CommitDate.UtcDateTime) + commitData.CommitDate.LocalDateTime.ToString(" (ddd MMM dd HH':'mm':'ss yyyy)"));
sb.AppendLine("\t\t" + commitData.Body.Trim(new char[] {'\n', '\r'}));
}
}
else
sb.AppendLine();
}
}
}
return sb.ToString();
}