added Rusty Checker
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Executable
+69
@@ -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
|
||||
Reference in New Issue
Block a user