public async Task <IReadOnlyList <UpdateResult> > Sync(SyncOutput syncOutput = SyncOutput.CreatePullRequest) { var list = new List <UpdateResult>(); foreach (var targetRepository in targets) { var targetRepositoryDisplayName = $"{targetRepository.Owner}/{targetRepository.Repository}"; using var syncer = new Syncer(targetRepository.Credentials, null, log); if (!await syncer.CanSynchronize(targetRepository, syncOutput, targetRepository.Branch)) { continue; } var syncContext = await CalculateSyncContext(targetRepository); if (!syncContext.Diff.ToBeAddedOrUpdatedEntries.Any()) { log($"Repo {targetRepositoryDisplayName} is in sync"); continue; } var sync = await syncer.Sync(syncContext.Diff, syncOutput, labelsToApplyOnPullRequests, syncContext.Description); var createdSyncBranch = sync.FirstOrDefault(); if (createdSyncBranch == null) { log($"Repo {targetRepositoryDisplayName} is in sync"); } else { log($"Pull created for {targetRepositoryDisplayName}, click here to review and pull: {createdSyncBranch}"); } list.Add(createdSyncBranch); } return(list); }
public async Task Sync(SyncOutput syncOutput = SyncOutput.CreatePullRequest) { foreach (var targetRepository in targets) { var targetRepositoryDisplayName = $"{targetRepository.Owner}/{targetRepository.Repository}"; using (var syncer = new Syncer(targetRepository.Credentials, null, log)) { if (!await syncer.CanSynchronize(targetRepository, syncOutput)) { continue; } var syncContext = await CalculateSyncContext(targetRepository); if (syncContext.Diff.ToBeAddedOrUpdatedEntries.Count() == 0) { log($"Repo {targetRepositoryDisplayName} is in sync"); continue; } var sync = await syncer.Sync(syncContext.Diff, syncOutput, labelsToApplyOnPullRequests, syncContext.Description); var createdSyncBranch = sync.FirstOrDefault(); if (string.IsNullOrEmpty(createdSyncBranch)) { log($"Repo {targetRepositoryDisplayName} is in sync"); } else { log($"Pull created for {targetRepositoryDisplayName}, click here to review and pull: {createdSyncBranch}"); } } } }