private static void Clone(List <string> platforms) { var task = GitHubCommand.GetAllRepositories(); task.Wait(); if (Directory.Exists("Repos")) { Directory.Delete("Repos", true); } Directory.CreateDirectory("Repos"); foreach (string platform in platforms) { CloneAllRepositoriesOfOnePlatform(platform, Path.Combine("Repos", platform), task.Result); } }
public static void CloneAllRepositoriesOfOnePlatform(string platform, string outputDirectory, IReadOnlyList <Repository> repos) { if (Directory.Exists(outputDirectory)) { Directory.Delete(outputDirectory, true); } Directory.CreateDirectory(outputDirectory); foreach (Repository repo in repos) { string sshUrl = repo.SshUrl; string gitName = sshUrl.Split('/').Last(); string repoName = gitName.Remove(gitName.Length - 4, 4); if (sshUrl.Contains(string.Format("-For{0}", platform))) { string result = GitHubCommand.Clone(sshUrl, outputDirectory, repoName); Console.WriteLine(result); break; } } }
private static void GetReadMe(List <string> platforms) { var task = GitHubCommand.GetAllRepositories(); task.Wait(); foreach (string platform in platforms) { string tempFolder = Path.Combine("ReadMe", platform); if (Directory.Exists(tempFolder)) { Directory.Delete(tempFolder, true); } Directory.CreateDirectory(tempFolder); foreach (Repository repo in task.Result) { string sshUrl = repo.SshUrl; string gitName = sshUrl.Split('/').Last(); string repoName = gitName.Remove(gitName.Length - 4, 4); if (sshUrl.Contains(string.Format("-For{0}", platform))) { string url = string.Format("https://raw.githubusercontent.com/ThinkGeo/{0}/master/README.md", repoName); try { WebClient client = new WebClient(); client.DownloadFile(new Uri(url), Path.Combine(tempFolder, repoName + ".md")); } catch (Exception err) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(err.Message); Console.ResetColor(); } Console.WriteLine($"Downloading {repoName}"); } } } }