static void OnEntryAdded(object o, SolutionItemEventArgs args)
{
if (args is SolutionItemChangeEventArgs && ((SolutionItemChangeEventArgs)args).Reloading)
{
return;
}
// handles addition of solutions and projects
SolutionItem parent = (SolutionItem)args.SolutionItem.ParentFolder;
if (parent == null)
{
return;
}
Repository repo = GetRepository(parent);
if (repo == null)
{
return;
}
SolutionItem entry = args.SolutionItem;
Repository currentRepo = GetRepository(entry);
if (currentRepo != null && currentRepo.VersionControlSystem != repo.VersionControlSystem)
{
// If the item is already under version control using a different version control system
// don't add it to the parent repo.
return;
}
string path = entry.BaseDirectory;
// While we /could/ call repo.Add with `recursive = true', we don't
// necessarily want to add files under the project/solution directory
// that may not be a part of this project/solution.
var files = new HashSet <string> {
path
};
SolutionItemAddFiles(path, entry, files);
using (IProgressMonitor monitor = GetStatusMonitor()) {
var status = repo.GetDirectoryVersionInfo(path, false, true);
foreach (var v in status)
{
if (!v.IsVersioned && files.Contains(v.LocalPath))
{
repo.Add(v.LocalPath, false, monitor);
}
}
}
NotifyFileStatusChanged(new FileUpdateEventArgs(repo, parent.BaseDirectory, true));
}