private bool IsValid(RepositoryToPull repo) { if (string.IsNullOrWhiteSpace(repo.UserName)) { return false; } Uri uri; if (!Uri.TryCreate(repo.Url, UriKind.Absolute, out uri)) { return false; } if (string.Compare("github.com", uri.Host, StringComparison.CurrentCultureIgnoreCase) != 0) { return false; } var pathParts = uri.AbsolutePath.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries); if (pathParts.Length != 2) { return false; } return true; }
internal void CloneRepository(RepositoryToPull entry) { var pwd = new DirectoryInfo(AppSettings.DestPath); if (!pwd.Exists) { pwd.Create(); } using (var tempFolder = new TemporaryFolder()) { var git = new GitLauncher(entry.HttpUrl, tempFolder); git.RunCloneToCompletion(); if (git.ExitCode != 0) { Console.WriteLine("Failed to download {0} on HTTP, trying SSH", entry.HttpUrl); git = new GitLauncher(entry.SshUrl, tempFolder); git.RunCloneToCompletion(); } if (git.ExitCode == 0) { Console.WriteLine("Succeeded downloading"); Console.WriteLine("Moving to {0}", pwd); } MoveResult(entry.UserName, tempFolder, pwd); } }