Last active
August 20, 2025 09:21
-
-
Save pawamoy/19d61162abaf9fe18df01bc0be265f37 to your computer and use it in GitHub Desktop.
Radicle badge, clone from Git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| rid=$(rad inspect --rid) || exit 1 | |
| echo "[](https://app.radicle.at/nodes/seed.radicle.at/${rid})" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| BASE58="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" | |
| get_git_rid() { | |
| local tempdir="$(mktemp -d)" || exit 1 | |
| git clone "${1}" --depth 1 "${tempdir}" || exit 1 | |
| local rid="$(grep -Em1 -o "rad:[${BASE58}]+" "${tempdir}/README.md")" || { | |
| echo "rad-git-clone: no Repository ID (RID) found in ${1}'s README" >&2 | |
| return 1 | |
| } | |
| echo "${rid}" | |
| } | |
| get_gh_rid() { | |
| get_git_rid "https://github.com/${1#gh:}" | |
| } | |
| main() { | |
| local arg | |
| local args=() | |
| local rid | |
| for arg in "$@"; do | |
| case "${arg}" in | |
| rad:*) rid="${arg}" ;; | |
| gh:*) rid="$(get_gh_rid "${arg}")" || exit 1 ;; | |
| -*) args+=("${arg}") ;; | |
| *) rid="$(get_git_rid "${arg}")" || exit 1 ;; | |
| esac | |
| done | |
| if [ -z "${rid}" ]; then | |
| rad clone "${args[@]}" | |
| else | |
| rad clone "${args[@]}" "${rid}" | |
| fi | |
| } | |
| main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment