]> git.corax.cc Git - foundry/commitdiff
distbot: Check more thoroughly if the specified repository exists
authorMatthias Kruk <m@m10k.eu>
Sun, 25 Apr 2021 03:53:25 +0000 (12:53 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 25 Apr 2021 03:53:25 +0000 (12:53 +0900)
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

index 5577a8bb1a7c7d4e835efd2f324630bab264bb90..6899e2cf1a8e4ca39175d1295095043c9700d78a 100755 (executable)
@@ -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"