Skip to content

fix(publish): normalize repository field#826

Merged
jdx merged 2 commits into
mainfrom
fix/publish-normalize-repository
Jun 3, 2026
Merged

fix(publish): normalize repository field#826
jdx merged 2 commits into
mainfrom
fix/publish-normalize-repository

Conversation

@jdx

@jdx jdx commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • normalize string repository values to { type, url } in the publish manifest
  • preserve existing repository objects unchanged
  • add publish-body tests for both shapes

Context

Inspired by pnpm 11.5.1 matching npm publish behavior for registries that reject string repository fields.

Tests

  • cargo test -p aube publish_body_ -- --nocapture
  • cargo fmt --check

This PR was generated by Codex.


Note

Low Risk
Localized publish-metadata shaping with tests; no auth, network, or tarball logic changes beyond the repository field format.

Overview
Publish now normalizes string repository values in the version metadata sent on PUT, so registries that reject bare strings (npm/pnpm-style) accept the payload.

When repository is a string, it is rewritten to { "type": "git", "url": "<normalized>" } via normalize_publish_manifest in build_publish_body. Shorthand forms (owner/repo, github:…, gitlab:…, bitbucket:…) expand to https://…/*.git URLs; explicit https://, git@, and fragments are preserved. Existing object repository values are left unchanged.

Unit tests cover normalized string output, preserved objects, and URL shorthand expansion.

Reviewed by Cursor Bugbot for commit 67cb61b. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Normalize the repository field in published package manifests so repository values are consistently stored as git objects; preserves explicit URLs and rejects empty strings.
  • Tests
    • Added tests validating shorthand expansion, string→object conversion, and preservation of already-object repository entries.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 094d8d29-12cc-44f4-a44c-0a9e8eb73318

📥 Commits

Reviewing files that changed from the base of the PR and between a962a55 and 67cb61b.

📒 Files selected for processing (1)
  • crates/aube/src/commands/publish.rs

📝 Walkthrough

Walkthrough

The PR adds repository field normalization to the publish manifest: string-form repository values are expanded/normalized into npm's { "type": "git", "url": ... } object form before the publish body is built; existing object-shaped repository values are preserved. Tests cover conversion, passthrough, and shorthand expansion.

Changes

Repository field normalization

Layer / File(s) Summary
Repository normalization implementation
crates/aube/src/commands/publish.rs
build_publish_body calls normalize_publish_manifest to mutate the serialized manifest: non-empty string repository fields are converted to { "type": "git", "url": ... } using normalize_repository_url; object-shaped repository values are left unchanged.
Repository normalization tests
crates/aube/src/commands/publish.rs
Unit tests verify that string repositories are normalized to git object form, existing object repositories are preserved, and shorthand repository syntaxes are expanded while explicit URLs/SSH are preserved.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I found a repo string in a crate,
I trimmed and checked it, made it straight.
Shorthands stretched to an HTTPS tune,
Objects left be, URLs immune.
Now publish sings beneath the moon.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(publish): normalize repository field' directly and clearly summarizes the main change: normalizing the repository field in the publish manifest.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/publish-normalize-repository

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR normalizes repository string values in the registry PUT body so registries that reject the npm shorthand form receive a proper {"type":"git","url":"..."} object instead. Repository fields that are already objects are passed through unchanged.

  • Adds normalize_publish_manifest (called once on the serialized manifest before the publish body is assembled) and a normalize_repository_url helper that expands github:, gitlab:, bitbucket:, and bare user/repo shorthands into canonical HTTPS .git URLs while leaving explicit :// and git@ URLs intact.
  • Adds four unit tests covering: string URL → object promotion, existing object preservation, shorthand expansion, and explicit URL passthrough.

Confidence Score: 5/5

Safe to merge — the change is scoped to manifest JSON shaping with no effect on auth, tarball generation, or network logic.

The normalization runs on a local serde_json::Value copy before the publish body is assembled, so a malformed or missing repository field simply falls through without modifying anything. All known npm shorthand forms are handled, existing object-shaped values are untouched, and the four new unit tests exercise every branching path in the new helpers.

No files require special attention.

Important Files Changed

Filename Overview
crates/aube/src/commands/publish.rs Adds normalize_publish_manifest and normalize_repository_url helpers to wrap string repository values in {type, url} objects before publishing, including expansion of npm shorthand forms (github:, gitlab:, bitbucket:, bare user/repo); four new unit tests cover all main paths.

Reviews (2): Last reviewed commit: "fix(publish): expand repository shorthan..." | Re-trigger Greptile

Comment thread crates/aube/src/commands/publish.rs Outdated
@jdx jdx merged commit 94eaef6 into main Jun 3, 2026
19 checks passed
@jdx jdx deleted the fix/publish-normalize-repository branch June 3, 2026 16:44
@greptile-apps greptile-apps Bot mentioned this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant