<commit_before>#!/bin/sh
if [ "${4%%/*}" = "branches" ]; then
	variant="LuCI ${4##*[-/]} Branch"
elif [ "${4%%/*}" = "tags" ]; then
	variant="LuCI ${4##*[-/]} Release"
else
	variant="LuCI Trunk"
fi

cat <<EOF > $1
local pcall, dofile, _G = pcall, dofile, _G

module "luci.version"

if pcall(dofile, "/etc/openwrt_release") and _G.DISTRIB_DESCRIPTION then
	distname    = ""<commit_msg>build: rewrite mkversion.sh to use git metadata (#239)<commit_after>#!/bin/sh

if svn info >/dev/null 2>/dev/null; then
	if [ "${4%%/*}" = "branches" ]; then
		variant="LuCI ${4##*[-/]} Branch"
	elif [ "${4%%/*}" = "tags" ]; then
		variant="LuCI ${4##*[-/]} Release"
	else
		variant="LuCI Trunk"
	fi
elif git status >/dev/null 2>/dev/null; then
	tag="$(git describe --tags 2>/dev/null)"
	branch="$(git symbolic-ref --short -q HEAD 2>/dev/null)"

	if [ -n "$tag" ]; then
		variant="LuCI $tag Release"
	elif [ "$branch" != "master" ]; then
		variant="LuCI ${branch##*-} Branch"
	else
		variant="LuCI Master"
	fi
else
	variant="LuCI"
fi

cat <<EOF > $1
local pcall, dofile, _G = pcall, dofile, _G

module "luci.version"

if pcall(dofile, "/etc/openwrt_release") and _G.DISTRIB_DESCRIPTION then
	distname    = ""
{'fraction_non_alphanumeric': 0.21644295302013422, 'fraction_numerical': 0.014261744966442953, 'mean_word_length': 4.033755274261603, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '305212', 'n_tokens_mistral': 494, 'n_tokens_neox': 471, 'n_words': 126}