Co-authored-by: Cyprien <courtot.c@gmail.com> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Laure Hugo <201583486+laure0303@users.noreply.github.com> Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Peter Evers <peter.evers@mistral.ai> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Yousria <yousria.debaud@mistral.ai> Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
25 lines
726 B
Bash
Executable file
25 lines
726 B
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
target_file="${1:-vibe/core/sentry.py}"
|
|
require_sentry_dsn="${REQUIRE_SENTRY_DSN:-false}"
|
|
|
|
if [ -z "${SENTRY_DSN:-}" ]; then
|
|
if [ "${require_sentry_dsn}" = "true" ]; then
|
|
echo "SENTRY_DSN is required but not set" >&2
|
|
exit 1
|
|
fi
|
|
echo "SENTRY_DSN is not set; leaving ${target_file} unchanged"
|
|
exit 0
|
|
fi
|
|
|
|
if ! grep -q '^_SENTRY_DSN = None$' "${target_file}"; then
|
|
echo "Expected Sentry placeholder not found in ${target_file}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
escaped_dsn="$(printf '%s' "${SENTRY_DSN}" | sed 's/[&|]/\\&/g')"
|
|
sed -i.bak "s|^_SENTRY_DSN = None$|_SENTRY_DSN = \"${escaped_dsn}\"|" "${target_file}"
|
|
rm -f "${target_file}.bak"
|
|
|
|
grep -q '^_SENTRY_DSN = ".*"$' "${target_file}"
|