diff --git a/repo-scripts/update-reference-config b/repo-scripts/update-reference-config new file mode 100755 index 0000000000000000000000000000000000000000..a2a60f6d46f47fd480d285372993d527a2a04083_cmVwby1zY3JpcHRzL3VwZGF0ZS1yZWZlcmVuY2UtY29uZmln --- /dev/null +++ b/repo-scripts/update-reference-config @@ -0,0 +1,30 @@ +#!/bin/bash +set -euo pipefail + +# This allow to update the yamlfile contained into a reference + +if [ $# -lt 1 ]; then + echo 'usage: update-reference REFERENCE.tar' + exit 64 +fi + +# create a temporta +tmpdir=`mktemp -d --suffix -tmp-perf-reference` + +# deletes the temp directory +function cleanup { + rm -rf "$tmpdir" +} +trap cleanup EXIT + +reference=`realpath "$1"` +tmpreference="${reference}~tmp-update" + +cp "${reference}" "${tmpreference}" +cd $tmpdir +datafile=`tar tf "${tmpreference}" | grep '.benchrepo$'` +tar xf "${tmpreference}" $datafile +"$EDITOR" $datafile +tar --delete --file "${tmpreference}" $datafile +tar --append --file "${tmpreference}" $datafile +mv "$tmpreference" "$reference" diff --git a/tests/test-make-reference.t b/tests/test-make-reference.t index eb6073d158e9d3434be1740e79e49d72dc5ccbfe_dGVzdHMvdGVzdC1tYWtlLXJlZmVyZW5jZS50..a2a60f6d46f47fd480d285372993d527a2a04083_dGVzdHMvdGVzdC1tYWtlLXJlZmVyZW5jZS50 100644 --- a/tests/test-make-reference.t +++ b/tests/test-make-reference.t @@ -149,3 +149,46 @@ my-reference-reference/.hg/store/data/nf9.i my-reference-reference/.hg/store/fncache my-reference.benchrepo + +update the reference +-------------------- + + $ EDITOR=cat update-reference-config my-reference-reference.tar + reference-repo: + id: my-reference + enabled: Yes + source: some-dir/my-source-repo + hg-version: 4.8+319-eb3d01b7c03a + number-revisions: + visible: 53 + all: 53 + number-heads: + visible: 3 + all: 3 + number-names-branch: + visible: 1 + all: 1 + $ cat << EOF > editor.sh + > #!/bin/bash + > sed -i 's,some-dir/my-source-repo,some-dir/my-other-source-repo,' \$1 + > EOF + $ chmod +x editor.sh + $ EDITOR=$PWD/editor.sh update-reference-config my-reference-reference.tar + $ mkdir dst + $ cd dst + $ tar xf ../my-reference-reference.tar my-reference.benchrepo + $ cat my-reference.benchrepo + reference-repo: + id: my-reference + enabled: Yes + source: some-dir/my-other-source-repo + hg-version: 4.8+319-eb3d01b7c03a + number-revisions: + visible: 53 + all: 53 + number-heads: + visible: 3 + all: 3 + number-names-branch: + visible: 1 + all: 1