Date: Tue, 7 Sep 2021 16:57:07 GMT From: Tobias Kortkamp <tobik@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: d8fbaa503cf2 - main - Scripts/cargo-crates.awk: Move split_url() to separate file Message-ID: <202109071657.187Gv7rc075806@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by tobik: URL: https://cgit.FreeBSD.org/ports/commit/?id=d8fbaa503cf286a4d61cd6d03e48b445fe5dfca4 commit d8fbaa503cf286a4d61cd6d03e48b445fe5dfca4 Author: Tobias Kortkamp <tobik@FreeBSD.org> AuthorDate: 2021-09-07 14:07:41 +0000 Commit: Tobias Kortkamp <tobik@FreeBSD.org> CommitDate: 2021-09-07 16:53:36 +0000 Scripts/cargo-crates.awk: Move split_url() to separate file Also stop leaking local variables --- Mk/Scripts/cargo-crates.awk | 30 ------------------------------ Mk/Scripts/split-url.awk | 29 +++++++++++++++++++++++++++++ Mk/Uses/cargo.mk | 2 +- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Mk/Scripts/cargo-crates.awk b/Mk/Scripts/cargo-crates.awk index 5949ca579fb9..7a17e746a945 100644 --- a/Mk/Scripts/cargo-crates.awk +++ b/Mk/Scripts/cargo-crates.awk @@ -46,36 +46,6 @@ function add_crate() { crate_source = "<unknown>" } -function split_url(s) { - # scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment] - split(s, url_scheme, "://") - url["scheme"] = url_scheme[1] - - split(url_scheme[2], url_fragment, "#") - url["fragment"] = url_fragment[2] - - split(url_fragment[1], url_query, "?") - url["query"] = url_query[2] - - split(url_query[1], url_authority, "/") - url["path"] = substr(url_query[1], length(url_authority[1]) + 1) - - split(url_authority[1], url_auth, "@") - - if (length(url_auth) == 2) { - split(url_auth[1], url_user, ":") - url["user"] = url_user[1] - url["password"] = url_user[2] - split(url_auth[2], url_host, ":") - } else { - url["user"] = "" - url["password"] = "" - split(url_auth[1], url_host, ":") - } - url["host"] = url_host[1] - url["port"] = url_host[2] -} - !gh_tuple_seen[$0] && /^source = "git\+(https|http|git):\/\/.*\/.*#.*"/ { gh_tuple_seen[$0] = 1 split_url(substr($3, 1 + length("\"git+"), length($3) - 1 - length("\"git+"))) diff --git a/Mk/Scripts/split-url.awk b/Mk/Scripts/split-url.awk new file mode 100644 index 000000000000..34506b527dd8 --- /dev/null +++ b/Mk/Scripts/split-url.awk @@ -0,0 +1,29 @@ +function split_url(s, url_scheme, url_fragment, url_query, url_authority, url_auth, url_user, url_host) { + # scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment] + split(s, url_scheme, "://") + url["scheme"] = url_scheme[1] + + split(url_scheme[2], url_fragment, "#") + url["fragment"] = url_fragment[2] + + split(url_fragment[1], url_query, "?") + url["query"] = url_query[2] + + split(url_query[1], url_authority, "/") + url["path"] = substr(url_query[1], length(url_authority[1]) + 1) + + split(url_authority[1], url_auth, "@") + + if (length(url_auth) == 2) { + split(url_auth[1], url_user, ":") + url["user"] = url_user[1] + url["password"] = url_user[2] + split(url_auth[2], url_host, ":") + } else { + url["user"] = "" + url["password"] = "" + split(url_auth[1], url_host, ":") + } + url["host"] = url_host[1] + url["port"] = url_host[2] +} diff --git a/Mk/Uses/cargo.mk b/Mk/Uses/cargo.mk index 7df138518f88..bd9c49b5c37d 100644 --- a/Mk/Uses/cargo.mk +++ b/Mk/Uses/cargo.mk @@ -349,7 +349,7 @@ cargo-crates: extract --verbose; \ fi @${SETENV} USE_GITHUB=${USE_GITHUB} USE_GITLAB=${USE_GITLAB} GL_SITE=${GL_SITE} \ - ${AWK} -f ${SCRIPTSDIR}/cargo-crates.awk ${CARGO_CARGOLOCK} + ${AWK} -f ${SCRIPTSDIR}/split-url.awk -f ${SCRIPTSDIR}/cargo-crates.awk ${CARGO_CARGOLOCK} # cargo-crates-licenses will try to grab license information from # all downloaded crates.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109071657.187Gv7rc075806>