<commit_before>#!/dev/null

if ! test "${#}" -eq 0 ; then
	echo "[ee] invalid arguments; aborting!" >&2
	exit 1
fi

env -i "${_git_env[@]}" "${_git_bin}" \
		submodule foreach --quiet \
			'echo "$( pwd ) ${name} ${sha1}"' \
| while read path name sha1 ; do
	path="$( readlink -e "${name}" )"
	name="$( basename "${name}" )"
	case "${name}" in
		( mosaic-repositories )
			orig_path="$( readlink -e ../mosaic-distribution-repositories )"
		;;
		( mosaic-dependencies )
			orig_path="$( readlink -e ../mosaic-distribution-dependencies )"
		;;
		( * )
			continue
		;;
	esac
	if test "${orig_path}" == "${path}" ; then
		continue
	fi
	if test ! -e "${orig_path}" ; then
		echo "[ww] ?? ${name}" >&2
		continue
	fi
	origin_sha1="$(
			cd "${orig_path}"
			exec env -i "${_git_env[@]}" "${_git_bin}" rev-parse HEAD
	)"
	if test "${sha1}" != "${origin_sha1}" ; then
		echo "[ww] ## ${name} -> ${origin_sha1}" >&2
		(
			cd "${path}"
			exec env -i "${_git_env[@]}" "${_git_bin}" fetch
		)
		if (
				cd "${path}"
				exec env -i "${_git_env[@]}" "${_git_bin}" cat-file -e "${origin_sha1}"
		) ; then (
				cd "${path}"
				exec env -i "${_git_env[@]}" "${_git_bin}" checkout "${origin_sha1}"
		) ; else
			echo "[ee] #### !!!!" >&2
		fi
	else
		echo "[ii] -- ${name}" >&2
	fi
done
<commit_msg>Update Git submodules advance script<commit_after>#!/dev/null

if ! test "${#}" -eq 0 ; then
	echo "[ee] invalid arguments; aborting!" >&2
	exit 1
fi

env -i "${_git_env[@]}" "${_git_bin}" \
		submodule foreach --quiet \
			'echo "$( pwd ) ${name} ${sha1}"' \
| while read path name sha1 ; do
	path="$( readlink -e "${name}" )"
	name="$( basename "${name}" )"
	case "${name}" in
		( mosaic-repositories )
			orig_path="$( readlink -e ../mosaic-distribution-repositories )"
		;;
		( mosaic-dependencies )
			orig_path="$( readlink -e ../mosaic-distribution-dependencies )"
		;;
		( * )
			continue
		;;
	esac
	if test "${orig_path}" == "${path}" ; then
		continue
	fi
	if test ! -e "${orig_path}" ; then
		echo "[ww] ?? ${name}" >&2
		continue
	fi
	origin_sha1="$(
			cd "${orig_path}"
			exec env -i "${_git_env[@]}" "${_git_bin}" rev-parse HEAD
	)"
	if test "${sha1}" != "${origin_sha1}" ; then
		echo "[ww] ## ${name} -> ${origin_sha1}" >&2
		(
			cd "${path}"
			exec env -i "${_git_env[@]}" "${_git_bin}" fetch
		)
		if (
				cd "${path}"
				exec env -i "${_git_env[@]}" "${_git_bin}" cat-file -e "${origin_sha1}"
		) ; then (
				cd "${path}"
				env -i "${_git_env[@]}" "${_git_bin}" \
						checkout "${origin_sha1}"
				env -i "${_git_env[@]}" "${_git_bin}" \
						submodule update --quiet --recursive --init --force
		) ; else
			echo "[ee] #### !!!!" >&2
		fi
	else
		echo "[ii] -- ${name}" >&2
	fi
done

{'fraction_non_alphanumeric': 0.2411242603550296, 'fraction_numerical': 0.011094674556213017, 'mean_word_length': 3.092284417549168, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '475130', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1030, 'n_words': 279}