Skip to content

[BUG] _parse_remote_url fails for SSH remotes with non-git usernames #1159

@NicklasNielsen

Description

@NicklasNielsen

Summary

apm audit --ci --policy org fails to discover the org policy when the git remote
uses a non-standard SSH username (anything other than git).

Steps to reproduce

  1. Have a git remote of the form <user>@<host>:<org>/<repo>.git where <user> is not git
  2. Run apm audit --ci --policy org

Expected behaviour

The org and host are extracted correctly and the org policy is discovered from <org>/.github/apm-policy.yml.

Actual behaviour

_parse_remote_url returns None because it guards with
if url.startswith("git@"), so _auto_discover returns:

"Could not determine org from git remote"

Root cause

In discovery.py, _parse_remote_url assumes the SSH username is always git:

if url.startswith("git@"):
    host_part, path_part = url.split(":", 1)
    host = host_part.replace("git@", "")

Environment (please complete the following information):

  • OS: Windows
  • Python Version: 3.13.3
  • APM Version: 0.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething does not work as documented.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions