#!/bin/bash
set -e

changesFile="/tmp/vn-repo.changes"

(
	flock -n 200 || exit

	if [ -f "$changesFile" ]; then
		while read -r line; do
				projectName=$(echo $line | cut -d" " -f1)
				branch=$(echo $line | cut -d" " -f2)

				vn-branch $projectName
		done < "$changesFile"

		rm $changesFile
	fi
) 200> /var/lock/vn-repo.lock