kibana/packages/kbn-handlebars/scripts/update_test_patches.sh
Kibana Machine f67c20d32f
[8.6] Add custom Buildkite pipeline for @kbn/handlebars (#146964) (#147275)
# Backport

This will backport the following commits from `main` to `8.6`:
- [Add custom Buildkite pipeline for @kbn/handlebars
(#146964)](https://github.com/elastic/kibana/pull/146964)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Thomas
Watson","email":"watson@elastic.co"},"sourceCommit":{"committedDate":"2022-12-08T17:28:33Z","message":"Add
custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses
#146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","v8.7.0"],"number":146964,"url":"https://github.com/elastic/kibana/pull/146964","mergeCommit":{"message":"Add
custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses
#146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146964","number":146964,"mergeCommit":{"message":"Add
custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses
#146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf"}}]}]
BACKPORT-->

Co-authored-by: Thomas Watson <watson@elastic.co>
2022-12-12 03:30:09 -07:00

39 lines
938 B
Bash
Executable file

#!/usr/bin/env bash
set -e
TMP=.tmp-handlebars
function cleanup {
rm -fr $TMP
}
trap cleanup EXIT
rm -fr $TMP
mkdir $TMP
echo "Cloning handlebars repo..."
git clone -q --depth 1 https://github.com/handlebars-lang/handlebars.js.git -b 4.x $TMP/handlebars
if [ -z "$1" ]
then
# No argument given: Update all patch files
files=(packages/kbn-handlebars/src/upstream/index.*.test.ts)
else
# Argument detected: Update only the requested patch file
files=(packages/kbn-handlebars/src/upstream/index.$1.test.ts)
fi
for file in "${files[@]}"
do
tmp=${file#*.} # remove anything before first period
file=${tmp%.test.ts} # remove trailing .test.ts
echo "Overwriting stored patch file for spec/$file.js..."
set +e
diff -d --strip-trailing-cr $TMP/handlebars/spec/$file.js packages/kbn-handlebars/src/upstream/index.$file.test.ts > packages/kbn-handlebars/.patches/$file.patch
set -e
done
echo "All patches updated :)"