Fix settings.py to use the correct databases

There was a bug in using "is" instead of "==" to compare hostnames, and
using next() on a list instead of an iterator.
Merge branch 'unstable' of https://github.com/ARmadillo-reuse/api-server
Fix permission error when checking branch

Use the directory name instead of calling out to git to determine whether to
select the stable or unstable database.