summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-09-10 14:54:25 +0200
committerJo-Philipp Wich <jo@mein.io>2022-10-25 01:03:36 +0200
commit447e362f0b56e5efdc2737899831297901736a0e (patch)
treecbf6a18bc68b7e3e0342f9f2c99cf67423336e1f
parent5c5f4a8d1f4560b5c0ac90402f5f957b166c96a3 (diff)
luci.mk: rework logic to determine current branch
In case `git branch --remote` yields no result, fall back to `git branch` without `--remote` since it is possible that the local branch has not been pushed yet. Also simplify extraction of the branch name by not passing `--verbose` and utilizing variable substitutions instead of sed expressions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--luci.mk7
1 files changed, 4 insertions, 3 deletions
diff --git a/luci.mk b/luci.mk
index bb4296aaed..7aaca0c24d 100644
--- a/luci.mk
+++ b/luci.mk
@@ -113,10 +113,11 @@ PKG_SRC_VERSION?=$(if $(DUMP),x,$(strip $(call findrev,1)))
PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \
variant="LuCI"; \
if git log -1 >/dev/null 2>/dev/null; then \
- branch="$$(git branch --remote --verbose --no-abbrev --contains 2>/dev/null | \
- sed -rne 's|^[^/]+/([^ ]+) [a-f0-9]{40} .+$$|\1|p' | head -n1)"; \
+ branch=$$(git branch --remote --no-abbrev --contains 2>/dev/null | tail -n1); \
+ branch=$${branch:-$$(git branch --no-abbrev --contains 2>/dev/null)}; \
+ branch=$${branch#? }; branch=$${branch#*/}; \
if [ "$$branch" != "master" ]; then \
- variant="LuCI $$branch branch"; \
+ variant="LuCI $${branch:-unknown} branch"; \
else \
variant="LuCI Master"; \
fi; \