#!/bin/bash
#
cd /space/dmueller/git-importer

source credentials.sh

while true; do
   for i in $PWD/tasks/*; do
       if test -f "$i"; then
            echo "$(date): Importing $(basename $i)"
            if ! python3 ./git-importer.py -c repos/.cache $(basename $i); then
                mkdir -p $PWD/failed-tasks
                mv -f $i $PWD/failed-tasks
            fi
            rm -f $i
        fi
   done
   inotifywait -q -e create $PWD/tasks
done