From nobody Tue Mar 19 14:20:39 2024 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TzYm815llz5FRQV; Tue, 19 Mar 2024 14:20:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TzYm75zgzz47Qn; Tue, 19 Mar 2024 14:20:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710858039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=W9a3btDIkN/Rjkew6j/A7qz1WWW4BGu254D31hXLzc4=; b=F90AN1TmW9f4z/2gHVtA7Yud1vVxjCqQclQZOx7iSmAccANOsvUvXC/r2nWPWYzmhcgCm6 1EC2BHKbfnRNuVIkT9AeHnf6Rv05oQHp20CRpjkadPXbDuQOUakuWat3ToWUWCnxqnbkBv cUdNS/7Nww6h9J1ULy3EBmZ4zd7d2lvJbXo+nD1RLevzESh3LBlaFgEhceKVn1/wNirNBx 2t9lr4aH2VBG7K7y93jR8IJ5/648a2czFeFwbMdq36SY0NNL5meV3E1wnpdmejYZK5oepr X84ACpLon1e98if+HvVR0r0HCZwjwU1J0Ys/mRHC1TDSW+/8u3yvxqxvh5kFdw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710858039; a=rsa-sha256; cv=none; b=Sz0LOjJf7b8wM/IrhcR1uY1Diedghdaio8KDu0QLYIy3SfBrd2n4ESuIlEa4nuL43xhgtE 5p9QT/d27InaQe5eMP37Z9bcGtq/OHRG5cjbolRa2msjkrpWl6Lypyvv5N3qpfdXlcYJor npwgU54iaLs0dqd5JGVdWCtOvUHjCon6EsOAPGNBdncoD0rhTY/wREVFVWaA7QTvYxS5E3 04k0vWjf3A/tgdJxOn4VKkKW1oqU0vgdI4ktZktLtKWb5IxzV2o/ScgWOqtxPsgHQEQF5I tquhwZGNu6dA9VjBvXgqxF1HpKWYZGmwDCtWGsgpgiiOP+0L0ck/6uL60UMJAw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710858039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=W9a3btDIkN/Rjkew6j/A7qz1WWW4BGu254D31hXLzc4=; b=iDCsLIjqUKUGLKq3Ggzf2iNfjLFczmU7AaEbz2rCwdd0ptmvcJLcGDOTsAO7loQz9+oM4C 7YQs8qO8VaQOXggFAKVvFXHlxo8LZN3PFGpXP/atPCc8ohvfmfXzzzu1jHZ4NoWUHAxjzm YywiL4rtusV4F7g2y3ZIQI6OsAvALZYjYTAzXcs5oPzni+CdhtSL39TejWR4jFcbaCYsAS CI8AMbReoYX99iv62gf0/W1AUcg125cr2H1ow4ogTu1RDpSZi46EPgwofF1yOTFfG0hs+2 bQsxlQhpkrj+7Rlg7tLwy7q0hkeuTDNGfZUiYAWngFQB3qNu13O9FlWu2m3XqQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TzYm75Hzqz193K; Tue, 19 Mar 2024 14:20:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42JEKd6j075902; Tue, 19 Mar 2024 14:20:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42JEKdqs075899; Tue, 19 Mar 2024 14:20:39 GMT (envelope-from git) Date: Tue, 19 Mar 2024 14:20:39 GMT Message-Id: <202403191420.42JEKdqs075899@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Robert Clausecker Subject: git: 849771c68290 - main - sysutils/gh-md-toc: Update to 0.10.0 List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fuz X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 849771c682905859f57d5c0a73dff421a88efc6e Auto-Submitted: auto-generated The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/ports/commit/?id=849771c682905859f57d5c0a73dff421a88efc6e commit 849771c682905859f57d5c0a73dff421a88efc6e Author: Jesús Daniel Colmenares Oviedo AuthorDate: 2024-03-15 00:51:19 +0000 Commit: Robert Clausecker CommitDate: 2024-03-19 14:18:51 +0000 sysutils/gh-md-toc: Update to 0.10.0 ChangeLog: https://github.com/ekalinin/github-markdown-toc/releases/tag/0.10.0 * Update for a new GH HTML layout PR: 276219 --- sysutils/gh-md-toc/Makefile | 7 +- sysutils/gh-md-toc/distinfo | 6 +- sysutils/gh-md-toc/files/patch-gh-md-toc | 251 +++++++++++++++++++++++++------ 3 files changed, 211 insertions(+), 53 deletions(-) diff --git a/sysutils/gh-md-toc/Makefile b/sysutils/gh-md-toc/Makefile index 6c4ba85a795d..aa18724b6d97 100644 --- a/sysutils/gh-md-toc/Makefile +++ b/sysutils/gh-md-toc/Makefile @@ -1,5 +1,5 @@ PORTNAME= gh-md-toc -DISTVERSION= 0.8.0 +DISTVERSION= 0.10.0 CATEGORIES= sysutils MAINTAINER= DtxdF@disroot.org @@ -9,7 +9,8 @@ WWW= https://github.com/ekalinin/github-markdown-toc LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE -RUN_DEPENDS= curl>0:ftp/curl +RUN_DEPENDS= curl>0:ftp/curl \ + jq>0:textproc/jq USE_GITHUB= yes GH_ACCOUNT= ekalinin @@ -21,7 +22,7 @@ PLIST_FILES= bin/gh-md-toc PORTDOCS= README.md -OPTIONS_DEFINE= DOCS +OPTIONS_DEFINE= DOCS do-install: ${INSTALL_SCRIPT} ${WRKSRC}/gh-md-toc ${STAGEDIR}${PREFIX}/bin diff --git a/sysutils/gh-md-toc/distinfo b/sysutils/gh-md-toc/distinfo index 16f7fc92da8d..1ed73e90898b 100644 --- a/sysutils/gh-md-toc/distinfo +++ b/sysutils/gh-md-toc/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1687043066 -SHA256 (ekalinin-github-markdown-toc-0.8.0_GH0.tar.gz) = 7f6079026a32c03d6e7254e5921b94f6802c2d52c9d74d85a1f8015d864b58d0 -SIZE (ekalinin-github-markdown-toc-0.8.0_GH0.tar.gz) = 10927 +TIMESTAMP = 1710461706 +SHA256 (ekalinin-github-markdown-toc-0.10.0_GH0.tar.gz) = d123d360b76e0ba97974cb32fb386905612d6b0ebb0a018161056062d9b44023 +SIZE (ekalinin-github-markdown-toc-0.10.0_GH0.tar.gz) = 24032 diff --git a/sysutils/gh-md-toc/files/patch-gh-md-toc b/sysutils/gh-md-toc/files/patch-gh-md-toc index ac4e37045b34..c2c5213ec763 100644 --- a/sysutils/gh-md-toc/files/patch-gh-md-toc +++ b/sysutils/gh-md-toc/files/patch-gh-md-toc @@ -1,4 +1,4 @@ ---- gh-md-toc.orig 2023-06-30 18:59:15 UTC +--- gh-md-toc.orig 2024-03-03 10:54:38 UTC +++ gh-md-toc @@ -1,4 +1,4 @@ -#!/usr/bin/env bash @@ -6,22 +6,23 @@ # # Steps: -@@ -34,12 +34,10 @@ gh_user_agent="gh-md-toc v$gh_toc_version" +@@ -34,12 +34,10 @@ gh_toc_load() { gh_toc_load() { local gh_url=$1 - if type curl &>/dev/null; then -+ if type curl > /dev/null 2>&1; then - curl --user-agent "$gh_user_agent" -s "$gh_url" +- curl --user-agent "$gh_user_agent" -s "$gh_url" - elif type wget &>/dev/null; then - wget --user-agent="$gh_user_agent" -qO- "$gh_url" ++ if type curl > /dev/null 2>&1; then ++ curl --location --fail --user-agent "$gh_user_agent" -s "$gh_url" else - echo "Please, install 'curl' or 'wget' and try again." + echo "Please, install 'curl' and try again." exit 1 fi } -@@ -56,7 +54,7 @@ gh_toc_md2html() { +@@ -58,7 +56,7 @@ gh_toc_md2html() { if [ ! -z "$GH_TOC_TOKEN" ]; then TOKEN=$GH_TOC_TOKEN else @@ -30,65 +31,221 @@ if [ -f "$TOKEN_FILE" ]; then TOKEN="$(cat $TOKEN_FILE)" fi -@@ -124,12 +122,14 @@ gh_toc(){ +@@ -109,6 +107,15 @@ gh_is_url() { + esac + } + ++gh_is_invalid_url() { ++ local gh_hostname="github.com" ++ ++ case $1 in ++ https://${gh_hostname}/* | http://${gh_hostname}/* ) return 0 ;; ++ *) return 1 ;; ++ esac ++} ++ + # + # TOC generator + # +@@ -139,75 +146,112 @@ gh_toc(){ fi if [ "$(gh_is_url "$gh_src")" == "yes" ]; then -- gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy" +- gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy" "$indent" - if [ "${PIPESTATUS[0]}" != "0" ]; then -+ local gh_content -+ gh_content=`gh_toc_load "$gh_src"` ++ if ! which -s "jq"; then ++ echo "Please, install 'jq' and try again." ++ exit 1 ++ fi ++ ++ if ! gh_is_invalid_url "${gh_src}"; then ++ echo "It looks like an invalid URL." ++ echo "Note that valid URLs are, for example, \"https://github.com//\"." ++ exit 1 ++ fi ++ ++ local account repo ++ ++ account=$(echo -n "${gh_src}" | sed -Ee 's#https?://github\.com/([^/]+).+#\1#') ++ repo=$(echo -n "${gh_src}" | sed -Ee 's#https?://github\.com/[^/]+/([^/]+)/?.*#\1#') ++ ++ local gh_content ++ gh_content=$(gh_toc_load "${gh_src}") + if [ $? -ne 0 ]; then echo "Could not load remote document." echo "Please check your url or network connectivity" exit 1 fi -+ printf "%s\n" "$gh_content" | gh_toc_grab "$gh_src_copy" ++ if [ "$need_replace" = "yes" ]; then echo echo "!! '$gh_src' is not a local file" -@@ -146,7 +146,7 @@ gh_toc(){ - if [ "$rawhtml" == "XXRateLimitXX" ]; then - echo "Parsing local markdown file requires access to github API" - echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting" -- TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt" -+ TOKEN_FILE="$(cd "$(dirname "$0")" && pwd)/token.txt" - echo "or place GitHub auth token here: ${TOKEN_FILE}" - exit 1 + echo "!! Can't insert the TOC into it." + echo ++ exit 1 + fi +- else +- local rawhtml=$(gh_toc_md2html "$gh_src" "$skip_header") +- if [ "$rawhtml" == "XXNetworkErrorXX" ]; then +- echo "Parsing local markdown file requires access to github API" +- echo "Please make sure curl is installed and check your network connectivity" +- exit 1 ++ ++ local json_file ++ json_file=$(mktemp -t gh-md-toc) ++ printf "%s\n" "${gh_content}" | grep defaultBranch | sed -Ee 's##\1#' > "${json_file}" ++ ++ local refName path ++ ++ refName=$(cat "${json_file}" | jq --raw-output '.props.initialPayload.overview.overviewFiles.[] | select(.preferredFileType == "readme") | .refName' 2> /dev/null) ++ path=$(cat "${json_file}" | jq --raw-output '.props.initialPayload.overview.overviewFiles.[] | select(.preferredFileType == "readme") | .path' 2> /dev/null) ++ ++ gh_src=$(mktemp -t gh-md-toc) ++ ++ gh_content=`gh_toc_load "https://raw.githubusercontent.com/${account}/${repo}/${refName}/${path}"` ++ if [ $? -ne 0 ]; then ++ echo "Could not load remote document." ++ echo "Please check your url or network connectivity" ++ exit 1 fi -@@ -175,11 +175,7 @@ gh_toc(){ - fi +- if [ "$rawhtml" == "XXRateLimitXX" ]; then +- echo "Parsing local markdown file requires access to github API" +- echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting" +- TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt" +- echo "or place GitHub auth token here: ${TOKEN_FILE}" +- exit 1 +- fi +- local toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent"` +- echo "$toc" +- if [ "$need_replace" = "yes" ]; then +- if grep -Fxq "" "$gh_src" && grep -Fxq "" "$gh_src"; then +- echo "Found markers" +- else +- echo "You don't have or in your file...exiting" +- exit 1 +- fi +- local ts="<\!--ts-->" +- local te="<\!--te-->" +- local dt=`date +'%F_%H%M%S'` +- local ext=".orig.${dt}" +- local toc_path="${gh_src}.toc.${dt}" +- local toc_createdby="" +- local toc_footer="" +- # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html +- # clear old TOC +- sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src" +- # create toc file +- echo "${toc}" > "${toc_path}" +- if [ "${no_footer}" != "yes" ]; then +- echo -e "\n${toc_createdby}\n${toc_footer}\n" >> "$toc_path" +- fi - # insert toc file -- if [[ "`uname`" == "Darwin" ]]; then +- # insert toc file +- if ! sed --version > /dev/null 2>&1; then - sed -i "" "/${ts}/r ${toc_path}" "$gh_src" - else - sed -i "/${ts}/r ${toc_path}" "$gh_src" - fi -+ sed -i "" "/${ts}/r ${toc_path}" "$gh_src" - echo - if [ "${no_backup}" = "yes" ]; then - rm ${toc_path} ${gh_src}${ext} -@@ -296,14 +292,18 @@ gh_toc_app() { - if [ "$1" = '--version' ]; then - echo "$gh_toc_version" - echo -- echo "os: `lsb_release -d | cut -f 2`" -- echo "kernel: `cat /proc/version`" -- echo "shell: `$SHELL --version`" -+ echo "os: `uname -rs`" -+ echo "kernel: `uname -K`" -+ echo "shell: $SHELL" - echo -- for tool in curl wget grep awk sed; do -+ for tool in grep awk; do - printf "%-5s: " $tool - echo `$tool --version | head -n 1` - done -+ printf "%-5s: " sed -+ echo "sed (BSD sed)" -+ printf "%-5s: " fetch -+ echo "fetch (BSD fetch)" - return +- echo +- if [ "${no_backup}" = "yes" ]; then +- rm "$toc_path" "$gh_src$ext" +- fi +- echo "!! TOC was added into: '$gh_src'" +- if [ -z "${no_backup}" ]; then +- echo "!! Origin version of the file: '${gh_src}${ext}'" +- echo "!! TOC added into a separate file: '${toc_path}'" ++ printf "%s\n" "${gh_content}" > "${gh_src}" ++ ++ rm -f "${json_file}" ++ fi ++ ++ local rawhtml=$(gh_toc_md2html "$gh_src" "$skip_header") ++ if [ "$rawhtml" == "XXNetworkErrorXX" ]; then ++ echo "Parsing local markdown file requires access to github API" ++ echo "Please make sure curl is installed and check your network connectivity" ++ exit 1 ++ fi ++ if [ "$rawhtml" == "XXRateLimitXX" ]; then ++ echo "Parsing local markdown file requires access to github API" ++ echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting" ++ TOKEN_FILE="$(cd "$(dirname "$0}")" && pwd)/token.txt" ++ echo "or place GitHub auth token here: ${TOKEN_FILE}" ++ exit 1 ++ fi ++ local toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent"` ++ echo "$toc" ++ if [ "$need_replace" = "yes" ]; then ++ if grep -Fxq "" "$gh_src" && grep -Fxq "" "$gh_src"; then ++ echo "Found markers" ++ else ++ echo "You don't have or in your file...exiting" ++ exit 1 + fi +- echo ++ local ts="<\!--ts-->" ++ local te="<\!--te-->" ++ local dt=`date +'%F_%H%M%S'` ++ local ext=".orig.${dt}" ++ local toc_path="${gh_src}.toc.${dt}" ++ local toc_createdby="" ++ local toc_footer="" ++ # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html ++ # clear old TOC ++ sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src" ++ # create toc file ++ echo "${toc}" > "${toc_path}" ++ if [ "${no_footer}" != "yes" ]; then ++ echo -e "\n${toc_createdby}\n${toc_footer}\n" >> "$toc_path" + fi ++ ++ # insert toc file ++ sed -i "" "/${ts}/r ${toc_path}" "$gh_src" ++ echo ++ if [ "${no_backup}" = "yes" ]; then ++ rm "$toc_path" "$gh_src$ext" ++ fi ++ echo "!! TOC was added into: '$gh_src'" ++ if [ -z "${no_backup}" ]; then ++ echo "!! Origin version of the file: '${gh_src}${ext}'" ++ echo "!! TOC added into a separate file: '${toc_path}'" fi ++ echo ++ fi + } + + # +@@ -218,7 +262,6 @@ gh_toc_grab() { + # $2 - number of spaces used to indent. + # + gh_toc_grab() { +- + href_regex="/href=\"[^\"]+?\"/" + common_awk_script=' + modified_href = "" +@@ -298,19 +341,21 @@ show_version() { + show_version() { + echo "$gh_toc_version" + echo +- echo "os: `uname -s`" ++ echo "os: `uname -rs`" + echo "arch: `uname -m`" +- echo "kernel: `uname -r`" +- echo "shell: `$SHELL --version`" ++ echo "kernel: `uname -i`" ++ echo "shell: $SHELL" + echo +- for tool in curl wget grep awk sed; do ++ for tool in curl grep awk jq; do + printf "%-5s: " $tool +- if `type $tool &>/dev/null`; then ++ if type $tool > /dev/null 2>&1; then + echo `$tool --version | head -n 1` + else + echo "not installed" + fi + done ++ printf "%-5s: " sed ++ echo "sed (BSD sed)" + } + show_help() {