|
|
@@ -20,10 +20,23 @@ namespace UsmWeb {
|
|
|
* One repository summary in the overview: the stats card fields plus the
|
|
|
* per-repository add-repository instruction fields ({@link base_uri},
|
|
|
* {@link usmr_href}, {@link repos_d_snippet}).
|
|
|
+ *
|
|
|
+ * Both repository kinds render a card; {@link kind} (the
|
|
|
+ * {@link RepositoryKind.to_string} wire name) picks which instruction
|
|
|
+ * block and stats the card shows — a USM card carries its package count
|
|
|
+ * and byte total, a DCBA card its artifact count and artifact byte
|
|
|
+ * total — that total sums the listing's `size` fields, so artifacts
|
|
|
+ * from listings written before the field existed (size 0) contribute
|
|
|
+ * nothing while still counting toward {@link artifact_count}. The
|
|
|
+ * `*_href`/`*_snippet` members are named for the USM card;
|
|
|
+ * a DCBA summary fills them with the `repo.dcbar` / `usm dcba
|
|
|
+ * add-repo` counterparts so the card markup stays one block with a
|
|
|
+ * kind branch.
|
|
|
*/
|
|
|
public class RepoSummary : Object {
|
|
|
public string name { get; set; default = ""; }
|
|
|
public string summary { get; set; default = ""; }
|
|
|
+ public string kind { get; set; default = "usm"; }
|
|
|
public int package_count { get; set; }
|
|
|
public string total_size { get; set; default = ""; }
|
|
|
public string href { get; set; default = ""; }
|
|
|
@@ -31,6 +44,8 @@ namespace UsmWeb {
|
|
|
public string base_uri { get; set; default = ""; }
|
|
|
public string usmr_href { get; set; default = ""; }
|
|
|
public string repos_d_snippet { get; set; default = ""; }
|
|
|
+ public int artifact_count { get; set; }
|
|
|
+ public string artifact_total_size { get; set; default = ""; }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -51,6 +66,20 @@ namespace UsmWeb {
|
|
|
* per-repository add instructions, and one combined table). Rows are
|
|
|
* filtered by the case-insensitive `query` substring over name and
|
|
|
* summary (an empty query keeps every entry).
|
|
|
+ *
|
|
|
+ * The overview lists repositories of **both** kinds as summary
|
|
|
+ * cards, in discovery order, but only the USM source repositories
|
|
|
+ * feed the package table and the package counts and byte totals —
|
|
|
+ * a DCBA entry contributes a card (its artifact count and artifact
|
|
|
+ * byte total from the `ARTIFACTS.usml` sizes) and nothing else, so
|
|
|
+ * pre-built artifacts surface in the detail views, never in the
|
|
|
+ * home package table.
|
|
|
+ *
|
|
|
+ * A repo-scoped build for a DCBA repository throws instead: the
|
|
|
+ * package-table state this builder authors does not describe an
|
|
|
+ * artifact repository, so the browse entrypoint degrades to its
|
|
|
+ * error card for those names (the dedicated DCBA browse view owns
|
|
|
+ * that page).
|
|
|
*/
|
|
|
public static State build(RepositoryService repositories, UsmWebConfig config,
|
|
|
ActionRegistry action_registry, string base_uri, string query, string? repo_name = null) throws Error {
|
|
|
@@ -66,6 +95,35 @@ namespace UsmWeb {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ if (entry.kind == RepositoryKind.DCBA) {
|
|
|
+ if (repo_name != null) {
|
|
|
+ throw new UsmWebError.INVALID_CONFIGURATION(
|
|
|
+ @"Repository \"$repo_name\" is a DCBA artifact repository — its pre-built artifacts are not listed as packages");
|
|
|
+ }
|
|
|
+
|
|
|
+ int64 artifact_bytes = 0;
|
|
|
+ uint artifact_count = 0;
|
|
|
+ foreach (var artifact_entry in entry.dcba_listing_entries()) {
|
|
|
+ artifact_bytes += (int64) artifact_entry.size;
|
|
|
+ artifact_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+ repo_rows.add(new RepoSummary() {
|
|
|
+ name = repo.name,
|
|
|
+ summary = repo.summary,
|
|
|
+ kind = RepositoryKind.DCBA.to_string(),
|
|
|
+ artifact_count = (int) artifact_count,
|
|
|
+ artifact_total_size = format_size(artifact_bytes),
|
|
|
+ href = "/repo/" + repo.name,
|
|
|
+ key_fingerprint = fingerprint(repo.key.to_hex()),
|
|
|
+ base_uri = base_uri + "repo/" + repo.name + "/",
|
|
|
+ usmr_href = base_uri + "repo/" + repo.name + "/repo.dcbar",
|
|
|
+ repos_d_snippet = "sudo usm dcba add-repo %srepo/%s/repo.dcbar"
|
|
|
+ .printf(base_uri, repo.name)
|
|
|
+ });
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
int64 repo_bytes = 0;
|
|
|
uint repo_count = 0;
|
|
|
var rows = new Vector<PackageRow>();
|
|
|
@@ -93,6 +151,7 @@ namespace UsmWeb {
|
|
|
repo_rows.add(new RepoSummary() {
|
|
|
name = repo.name,
|
|
|
summary = repo.summary,
|
|
|
+ kind = RepositoryKind.USM.to_string(),
|
|
|
package_count = (int) repo_count,
|
|
|
total_size = format_size(repo_bytes),
|
|
|
href = "/repo/" + repo.name,
|