From 5614057d790ecb0b8516d4e9cdfb5ebe427f805b Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Sun, 25 Apr 2021 12:53:25 +0900 Subject: [PATCH] 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. --- distbot.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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" -- 2.47.3