From 5a5eed8c7c0aba68c44dc6749813e9e2b09a3066 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Wed, 29 Apr 2020 16:38:27 +0200 Subject: [PATCH] Support project build from URL (closes #14) --- git-build.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/git-build.sh b/git-build.sh index bbeecc0..3881f34 100755 --- a/git-build.sh +++ b/git-build.sh @@ -36,8 +36,20 @@ PROJECTS=() for arg in "$@"; do if [[ "$arg" = "-f" ]] || [[ "$arg" = "--force" ]]; then FORCE=1 + # Maybe it's a task name and we find a corresponding source? elif [ -f $BASEDIR/$arg.source ]; then PROJECTS+=("$arg") + # Maybe it's a repo URL and we find a corresponding task? + elif matches="$(grep --files-with-matches --word-regexp "$arg" $BASEDIR/*.source)"; then + # Iterate over the files found to extract the task name + IFS= echo "$matches" | while read -r file; do + task_name="$(basename "$file" .source)" + # Make sure we don't have a .source file without name lying around, just in case + [[ "$task_name" != "" ]] && PROJECT+=("$task_name") + done + else + echo "ERROR: Unknown argument '$arg' (doesn't match a task name or source URL)" + exit 1 fi done