Skip to content

fix(core): parse local diffs and repository URLs independently of git config and host - #412

Merged
parse merged 3 commits into
mainfrom
fix/git-and-repo-url-parsing
Nov 18, 2026
Merged

parse merged 3 commits into
mainfrom
fix/git-and-repo-url-parsing

Conversation

@parse

@parse parse commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #411.

What changed

  • Local diffs (utils/git-diff.ts, new diff-sections.ts): git runs with -c core.quotePath=false, --no-color, --no-ext-diff, --src-prefix=a/ --dst-prefix=b/ and LC_ALL=C. File list and stats come from --name-status -z and --numstat -z. diff.noprefix, diff.mnemonicPrefix, a non-English locale, non-ASCII paths, paths containing b/, renames, type changes and binary files no longer break parsing.
  • One repo locator (utils/repo-locator.ts): replaces six parsers (git-diff remotes, url-utils, model-source, the three PR readers, platform detection, the CLI schema). Handles https/http, ssh:// with port, git+ssh, git://, scp form, owner/repo, www., host:port/path, GitLab nested groups and /-/ suffixes, Azure DevOps and Bitbucket Server paths. Credentials are never copied into its output.
  • Self-hosted hosts: ERODE_GITHUB_BASE_URL, ERODE_GITLAB_BASE_URL and ERODE_BITBUCKET_BASE_URL hosts, including context paths such as https://host/gitlab, are recognised for model links, remotes and PR/MR URLs. GitHub Enterprise now passes its base URL to Octokit.
  • PR/MR URLs (platforms/change-request-url.ts): parsed with URL; the marker must follow the repo path directly; /files, /diffs, query and fragment are accepted.
  • Model repo clone: tokens are only attached to https URLs; ssh and git:// are cloned as given. .git.git and /-/tree/... slug bugs are fixed.
  • Errors: unknown hosts name the ERODE_*_BASE_URL settings.
  • Docs: ADR-013; CLI, configuration and CI integration pages.

Behaviour changes

  • Host-only or org-only links (https://github.com/org) no longer count as repository links, so erode validate may report those components as unlinked.
  • A private model repo given as http:// is cloned without a token and fails to authenticate (a warning explains why).
  • Local file status can be changed (type change) or unmerged; filesChanged counts numstat entries.

Review follow-ups

  • Tokens are only sent to the configured instance or the public host for that platform; a path that looks like Bitbucket Server on another host gets no token. With a self-hosted base URL set, the public host gets no token.
  • Quoted git paths decode whole UTF-8 code points (emoji), and quoted no-prefix headers are decoded.
  • Platform API and token follow the change request's host: the configured instance uses ERODE_*_BASE_URL and its token; github.com, gitlab.com and bitbucket.org use the public API without the instance token; other hosts are rejected with a message naming the setting. Before, a public github.com PR URL was fetched from a configured GitHub Enterprise server.

Checks

Check Result
check:ci pass
knip pass
Tests 1341 core + 10 cli pass, incl. a real temp git repo with hostile config and filenames

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@parse
parse added this pull request to stack #414 November 17, 2026 17:21
@parse
parse force-pushed the fix/git-and-repo-url-parsing branch from 9e9c450 to 7015d62 Compare November 17, 2026 17:49
@parse
parse marked this pull request as ready for review November 17, 2026 17:49
@parse
parse requested a review from a team as a code owner November 17, 2026 17:49
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] This PR appears safe to merge.

Summary

This PR brings repository URL parsing into one place and makes local Git diffs more reliable across user settings and unusual filenames.

  • Structurizr updates use DSL identifiers to find elements and patch references.
  • Local checks read Git diffs consistently, even with unusual paths and Git settings.
  • Repository links and remotes now share one set of parsing rules.
  • Change-request readers use the URL's host and matching API credentials.

No new actionable issues found.

Reviews (5) · Last reviewed commit: "fix(core): pick the platform API from th..." · Reviewed by Greptile

Comment thread packages/core/src/utils/repo-locator.ts Resolved
@parse
parse force-pushed the fix/git-and-repo-url-parsing branch from 7015d62 to 6319a26 Compare November 17, 2026 18:09
@parse
parse force-pushed the fix/git-and-repo-url-parsing branch from b924c41 to 4ff5d84 Compare November 18, 2026 07:16
@parse
parse force-pushed the fix/git-and-repo-url-parsing branch 2 times, most recently from fa9271a to 2c7656b Compare November 18, 2026 07:22
Base automatically changed from fix/structurizr-identifiers to main November 18, 2026 07:24
… config and host

- Local git diffs run with fixed prefixes, no color, no external diff,
  core.quotePath=false and LC_ALL=C; file list and stats come from
  --name-status -z and --numstat -z
- One shared repo locator replaces six parsers for remotes, model links,
  model repos and PR/MR URLs, including ssh with port, git://, scp form,
  GitLab nested groups, Azure DevOps and Bitbucket Server paths
- Self-hosted GitHub, GitLab and Bitbucket base URLs (with context paths)
  are honoured; GitHub Enterprise passes its base URL to Octokit
- Model repo tokens are only sent over https
- ADR-013
- Send a platform token to a model repository only when its host, port and
  base path match the configured instance for that token (ERODE_*_BASE_URL),
  or the public host when none is configured. A path shape such as
  /scm/KEY/repo no longer decides on its own that a token is sent.
- Decode C-quoted git paths as one UTF-8 byte buffer, encoding literal
  characters by code point, so names like src/😀".ts survive.
- Decode quoted diff headers before matching prefixes, so quoted no-prefix
  and mnemonic-prefix headers resolve to the real path.
A public PR URL was fetched from the configured self-hosted API, so erode
could analyse a same-named repository there and send the instance token.
Readers and writers now resolve the endpoint from the URL host: the public
host uses the public API without the token, the configured instance uses
ERODE_*_BASE_URL with its token, and any other host is rejected naming the
host and the setting. Applies to GitHub, GitLab and Bitbucket.
@parse
parse force-pushed the fix/git-and-repo-url-parsing branch from 2c7656b to cfe6569 Compare November 18, 2026 07:24
@parse
parse merged commit 38d4961 into main Nov 18, 2026
9 checks passed
@parse
parse deleted the fix/git-and-repo-url-parsing branch November 18, 2026 07:26
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