From: Matthias Kruk Date: Sun, 25 Apr 2021 03:53:25 +0000 (+0900) Subject: distbot: Check more thoroughly if the specified repository exists X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=5614057d790ecb0b8516d4e9cdfb5ebe427f805b;p=foundry distbot: Check more thoroughly if the specified repository exists Distbot assumes that the repository has been initialized if the directory exists. This means that the repository won't be initialized if an empty directory was passed to distbot. This commit makes distbot check the specified repository a little more thoroughly, to make sure empty directories will be initialized, too. --- diff --git a/distbot.sh b/distbot.sh index 5577a8b..6899e2c 100755 --- a/distbot.sh +++ b/distbot.sh @@ -126,6 +126,20 @@ watch_new_packages() { return 0 } +looks_like_a_repository() { + local path="$1" + + if ! [ -d "$path" ]; then + return 1 + fi + + if ! [ -d "$path/incoming" ]; then + return 1 + fi + + return 0 +} + main() { local path local codename @@ -155,7 +169,7 @@ main() { gpgkey=$(opt_get "gpgkey") desc=$(opt_get "description") - if ! [ -d "$path" ]; then + if ! looks_like_a_repository "$path"; then # Create new repository log_info "Initializing repository $name:$codename in $path"