From 4f82defa60f8acc15180b502b2a4d4e4ca7295fb Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Thu, 25 May 2017 11:35:40 +0100 Subject: [PATCH] bin: add `repo-root` Signed-off-by: Alejandro Mery --- files/bin/repo-root | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 files/bin/repo-root diff --git a/files/bin/repo-root b/files/bin/repo-root new file mode 100755 index 0000000..9e0d11f --- /dev/null +++ b/files/bin/repo-root @@ -0,0 +1,15 @@ +#!/bin/sh + +set -ue +d="$PWD" +while true; do + if [ "${d:-/}" = / ]; then + echo "$PWD" + exit 1 + elif [ -s "$d/.repo/manifest.xml" ]; then + break + else + d="$(cd "$d/.." && pwd)" + fi +done +echo "$d"