private static int Run(CommandLineApplication app, List <string> repos, string reposFile, bool doCommit, string baseBranchName, string changesBranchName, string commitMessage, bool push, bool createPr, bool cleanup, string commandToRun) { if (!TryLoadUrls(repos, reposFile, out var urls)) { return(1); } else if (!urls.Any()) { Console.Error.WriteLine("Error: No repository urls provided."); app.ShowHelp(); return(1); } if (doCommit && string.IsNullOrWhiteSpace(commitMessage)) { Console.Error.WriteLine("Error: Specify a commit message with --commit-message when using --commit or --pull-request"); app.ShowHelp(); return(1); } if (createPr && string.IsNullOrWhiteSpace(changesBranchName)) { Console.Error.WriteLine("Error: Specify a branch to create with --changes-branch when using --pull-request"); app.ShowHelp(); return(1); } var credentials = GetCredentials(); foreach (var repoUrl in urls) { RepositoryProcessor processor = null; try { processor = new RepositoryProcessor(repoUrl, credentials); if (!string.IsNullOrWhiteSpace(baseBranchName)) { processor.CheckoutBaseBranch(baseBranchName); } if (!string.IsNullOrWhiteSpace(changesBranchName)) { processor.CreateChangesBranch(changesBranchName); } processor.RunCommand(commandToRun); if (!doCommit || !processor.HasChanges) { continue; } processor.Commit(commitMessage); if (push) { processor.Push(); } if (createPr) { processor.CreatePullRequest(commitMessage); } } finally { // Wether success or failure, clean up the cloned repository if (cleanup && processor != null) { processor.Cleanup(); } } } return(0); }