luci.mk: fix branch detection in detached HEAD state
authorJo-Philipp Wich <jo@mein.io>
Mon, 20 Feb 2017 13:14:49 +0000 (14:14 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 20 Feb 2017 13:16:26 +0000 (14:16 +0100)
When LuCI is checked out via pinned feeds configuration, its source tree will
end up in detached head state, requiring some more magic to figure out the
proper branch.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
luci.mk

diff --git a/luci.mk b/luci.mk
index 69aecaa250578a821665e186244dfa53026fa66f..26f3c94f902df5556e55941c8891326cdaa34a6e 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -70,7 +70,9 @@ PKG_VERSION?=$(if $(DUMP),x,$(strip $(shell \
 PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \
        variant="LuCI"; \
        if git log -1 >/dev/null 2>/dev/null; then \
-               branch="$$(git symbolic-ref --short -q HEAD 2>/dev/null)"; \
+               branch="$$(git symbolic-ref --short -q HEAD 2>/dev/null || \
+                       git branch --remote --verbose --no-abbrev --contains 2>/dev/null | \
+                               sed -e 's|^.*/||; s| .*||; q')"; \
                if [ "$$branch" != "master" ]; then \
                        variant="LuCI $$branch branch"; \
                else \