From ac54a727324448f4ba9c9b8549bbc381a8868a08 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Fri, 30 Jan 2026 11:57:46 +0200 Subject: [PATCH] added Rusty Checker --- README.md | 1 + outport | 2 +- rusty-checker.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 rusty-checker.sh diff --git a/README.md b/README.md index 6b48497..96d129d 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,4 @@ * [ShellBeat](./shellbeat.sh): a [bytebeat](https://stellartux.github.io/websynth/guide.html) audio formula player in pure shell (also depends on xxd) * [GHMD](./ghmd.sh): a command suite to set up your own self-hosted Git repositories * [Multicities](./cities.sh): Neocities static site manager with multiple account support +* [Rusty Checker](./rusty-checker.sh): quickly check if a public FOSS project is written in Rust (or another language that you pass to the script) diff --git a/outport b/outport index c94c626..1d39eab 100755 --- a/outport +++ b/outport @@ -12,7 +12,7 @@ case "$ACTION" in start) while :; do [ -z "$1" ] && break - PORT_OPTS="$PORT_OPTS -R :$1:localhost:$1" + PORT_OPTS="$PORT_OPTS -R 0.0.0.0:$1:localhost:$1" shift done MISC_OPTS="-o ServerAliveInterval=60 -o ServerAliveCountMax=15" diff --git a/rusty-checker.sh b/rusty-checker.sh new file mode 100755 index 0000000..a59f37e --- /dev/null +++ b/rusty-checker.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# Rusty checker: check if a FOSS project is written in Rust (by default) +# or another language of your selection +# Usage: rusty-checker.sh repo_url [lang] +# Currently only supports GitHub, GitLab and Codeberg +# More provider support may come if there's some public API +# Depends on grep, curl and jq +# Created by Luxferre in 2026, released into public domain + +PROV="" +TGT="" +REPO="$1" +CHLANG=Rust +[ ! -z "$2" ] && CHLANG="$2" +echo "$REPO" | grep -qi "github.com" && PROV="gh" +echo "$REPO" | grep -qi "gitlab.com" && PROV="gl" +echo "$REPO" | grep -qi "codeberg.org" && PROV="cb" +# Remove trailing slash before processing +REPO="${REPO%/}" +temp="${REPO%.git}" + +CORR_SCORE=0 # innocent until proven guilty + +if [ "$PROV" = "gh" ]; then + TGT="${temp#*github.com/}" + ROOT_URL="https://api.github.com/repos/$TGT" + LANG_URL="" +elif [ "$PROV" = "gl" ]; then + TGT="${temp#*gitlab.com/}" + ROOT_URL="https://gitlab.com/api/v4/projects/${TGT/\//%2F}" + LANG_URL="${ROOT_URL}/languages" +elif [ "$PROV" = "cb" ]; then + TGT="${temp#*codeberg.org/}" + ROOT_URL="https://codeberg.org/api/v1/repos/$TGT" + LANG_URL="" +else + echo 'This provider is currently unsupported, sorry!' + exit 2 +fi + +repodata="$(curl -sSL $ROOT_URL)" +[ -z "$LANG_URL" ] && LANG_URL="$(echo $repodata | jq -r .languages_url)" +langdata="$(curl -sSL $LANG_URL)" +desc="$(echo $repodata | jq -r .description)" +topics=$(echo $repodata | jq -r .topics) +# mentioning the language in the description boosts the score a lot +echo "$desc" | grep -qi "$CHLANG" && CORR_SCORE=$((CORR_SCORE + 50)) +# mentioning the language in the topics also boosts the score +echo "$topics" | grep -qi "$CHLANG" && CORR_SCORE=$((CORR_SCORE + 30)) +# get the most popular language in the language list +mainlang="$(echo "$langdata" | jq -r 'to_entries | max_by(.value) | .key')" +# just using this language increases the score by 10 +echo "$langdata" | grep -qi "$CHLANG" && CORR_SCORE=$((CORR_SCORE + 10)) +# but if it is the main one, we further increase the score by 50 +echo "$mainlang" | grep -qi "$CHLANG" && CORR_SCORE=$((CORR_SCORE + 50)) + +if ((CORR_SCORE >= 50)); then + echo "The project $TGT is most likely written in $CHLANG." + if ((CORR_SCORE >= 100)); then + echo 'The author is a definite fanatic of this language.' + fi + exit 0 +else + echo "The project $TGT does not seem to be written in $CHLANG." + if ((CORR_SCORE > 0)); then + echo 'However, this language may be partially used there.' + fi + exit 1; +fi