public void RunGitMigration(ref CancellationTokenSource cts) { List <GitTransferEntry> records; using (var reader = new StreamReader(_localConfiguration.TransferListCsvFullPath)) using (var csv = new CsvReader(reader)) { csv.Configuration.Delimiter = ";"; records = csv.GetRecords <GitTransferEntry>().ToList(); foreach (var record in records) { if (cts.IsCancellationRequested) { break; } try { string tempWorkingDirectory = $"{_localConfiguration.TempWorkingDirectory}\\{record.SourceProjectName}\\{record.SourceSubProjectName}"; _directoryService.ClearTempFolder(tempWorkingDirectory); if (!CloneGitRepository(string.Format(_sourceConnectionConfiguration.AzureDevOpsUrl, _sourceConnectionConfiguration.AzureDevOpsCollectionName, record.SourceProjectName, record.SourceSubProjectName), record.SourceBranchName, tempWorkingDirectory)) { _logger.Log("ERROR: DownloadGitRepository went wrong"); continue; } if (cts.IsCancellationRequested) { break; } if (!RemoveOrigin(tempWorkingDirectory)) { _logger.Log("ERROR: RemoveOrigin went wrong"); continue; } string destinationRepoUrl = CreateGitRepository(_targetConnectionConfiguration.AzureDevOpsUrl, record.TargetProjectName, record.TargetRepoName, _targetConnectionConfiguration.PersonalAccessToken); if (destinationRepoUrl.Length == 0) { _logger.Log("ERROR: destinationRepoUrl.Length == 0"); continue; } if (!AddOrigin(tempWorkingDirectory, destinationRepoUrl)) { _logger.Log("ERROR: AddOrigin went wrong"); continue; } if (cts.IsCancellationRequested) { break; } if (!PushToRepository(tempWorkingDirectory)) { _logger.Log("ERROR: PushToRepository went wrong"); continue; } record.TransferedSuccessfully = true; } catch (Exception ex) { _logger.Log($"Uncaught Exception: {ex.Message}"); _logger.Log(ex.ToString()); } } } using (var writer = new StreamWriter(_localConfiguration.TransferListCsvFullPath)) using (var csv = new CsvWriter(writer)) { csv.Configuration.Delimiter = ";"; csv.WriteRecords(records); } }