apm_github_resolve_url (private)

 apm_github_resolve_url -url url

Defined in packages/acs-tcl/tcl/apm-file-procs.tcl

Resolve various github.com URLs to an archive tarball URL plus an optional subpath (for /tree/REF/<path>). Returns a dict with keys: kind github tarball <url-to-.tar.gz> subpath <path-within-repo-or-empty>

Switches:
-url (required)

Partial Call Graph (max 5 caller/called nodes):
apm_load_apm_file apm_load_apm_file (public) apm_github_resolve_url apm_github_resolve_url apm_load_apm_file->apm_github_resolve_url

Testcases:
No testcase defined.
Source code:
    # Examples:
    #  https://github.com/O/R
    #  https://github.com/O/R/tree/REF
    #  https://github.com/O/R/tree/REF/path/to/pkg
    #
    # Use HEAD tarball when no REF is specified.
    set re {^https?://github\.com/([^/]+)/([^/]+)(?:/tree/([^/]+)(?:/(.*))?)?/?$}
    if {![regexp -- $re $url -> owner repo ref subpath]} {
        return -code error "not a supported github url: $url"
    }
    # Trim possible ".git"
    regsub {\.git$} $repo "" repo

    if {$ref eq ""} {
        # GitHub supports .../archive/HEAD.tar.gz
        set tarball "https://github.com/$owner/$repo/archive/HEAD.tar.gz"
    } else {
        # We don’t know if REF is a branch or tag; GitHub accepts archive/<ref>.tar.gz too,
        # but HEAD.tar.gz is easiest. Still, tree/REF implies a specific ref.
        set tarball "https://github.com/$owner/$repo/archive/$ref.tar.gz"
    }
    if {$subpath eq ""} {
        set subpath ""
    }

    return [list kind github tarball $tarball subpath $subpath]
Generic XQL file:
packages/acs-tcl/tcl/apm-file-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/apm-file-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/apm-file-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: