Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ await AnsiConsole.Live(table)
ctx.UpdateTarget(RenderTable(summaries));
}

//// Repos (pseudo-code)
//summary.TotalRepos = await _catalogService.CountReposAsync(project.Name);
//summary.IsRepoComplete = true;
//ctx.UpdateTarget(RenderTable(summaries));
// Repos
await foreach (var repoStat in catalogService.CountRepositoriesAsync(settings.Organisation, project, settings.Token))
{
summary.ReposCount = repoStat.ReposCount;
summary.IsRepoComplete = repoStat.IsRepoComplete;
summary.LastUpdatedUtc = repoStat.LastUpdatedUtc;
ctx.UpdateTarget(RenderTable(summaries));
}

//// Pipelines (pseudo-code)
//summary.TotalPipelines = await _catalogService.CountPipelinesAsync(project.Name);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.Common;
Expand Down Expand Up @@ -83,6 +84,27 @@ public async IAsyncEnumerable<ProjectDiscoverySummary> CountAllWorkItemsAsync(
} while (batchCount == maxPerBatch);
}


public async IAsyncEnumerable<ProjectDiscoverySummary> CountRepositoriesAsync(
string orgUrl,
string project,
string pat,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var credentials = new VssBasicCredential(string.Empty, pat);
var connection = new VssConnection(new Uri(orgUrl), credentials);
var gitClient = connection.GetClient<GitHttpClient>();

ProjectDiscoverySummary repoStats = new ProjectDiscoverySummary();

// Get all repositories for the project
var repositories = await gitClient.GetRepositoriesAsync(project, cancellationToken: cancellationToken);

// Set the repository count
repoStats.ReposCount = repositories.Count;
repoStats.IsRepoComplete = true;
repoStats.LastUpdatedUtc = DateTime.UtcNow;

yield return repoStats;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace MigrationPlatform.Abstractions.Services
public interface ICatalogService
{
IAsyncEnumerable<ProjectDiscoverySummary> CountAllWorkItemsAsync(string orgUrl, string project, string pat, CancellationToken cancellationToken = default);
IAsyncEnumerable<ProjectDiscoverySummary> CountRepositoriesAsync(string orgUrl, string project, string pat, CancellationToken cancellationToken = default);
Task<IReadOnlyList<string>> GetProjectsAsync(string orgUrl, string pat);

}
}