public async Task SearchAsync() { var drives = System.IO.Directory.GetLogicalDrives(); foreach (var drive in drives) { var gitFolders = FindGitFolders(drive); foreach (var gitFolder in gitFolders) { var gitFolderPath = gitFolder.Replace("\\.git", string.Empty); var gitRepoName = gitFolderPath.Substring(gitFolderPath.LastIndexOf("\\", StringComparison.Ordinal) + 1); await _talkAgent.SayAsync("Found git repo " + gitRepoName + "."); _repositoryBusiness.Add(gitRepoName, gitFolderPath); } } }
public async override Task ExecuteAsync(string key, string phrase) { string path = null; while (path == null) { path = await _questionAgent.AskFolderAsync("Please select the folder where the repository is located."); if (path == null) { await _talkAgent.SayAsync("Okey, so you changed your mind."); return; } if (!System.IO.Directory.Exists(path + "\\.git")) { await _talkAgent.SayAsync("I cannot find the '.git' folder in this path."); path = null; } } var name = await _questionAgent.AskStringAsync("What name do you want for the repository?"); if (!string.IsNullOrEmpty(name)) { _settingAgent.SetSetting("Repositories", name, path); await _talkAgent.SayAsync("I have selected repository " + name + " for you."); _repositoryBusiness.Select(name); _repositoryBusiness.Add(name, path); } else { await _talkAgent.SayAsync("Open repository was aborted."); } }