...
1#!/bin/bash
2#
3# Copyright 2022 The Go Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style
5# license that can be found in the LICENSE file.
6#
7# Creates a zip file containing all numbered versions
8# of the commit history of a large source file, for use
9# as input data for the tests of the diff algorithm.
10#
11# Run script from root of the x/tools repo.
12
13set -eu
14
15# WARNING: This script will install the latest version of $file
16# The largest real source file in the x/tools repo.
17# file=internal/golang/completion/completion.go
18# file=internal/golang/diagnostics.go
19file=internal/protocol/tsprotocol.go
20
21tmp=$(mktemp -d)
22git log $file |
23 awk '/^commit / {print $2}' |
24 nl -ba -nrz |
25 while read n hash; do
26 git checkout --quiet $hash $file
27 cp -f $file $tmp/$n
28 done
29(cd $tmp && zip -q - *) > testdata.zip
30rm -fr $tmp
31git restore --staged $file
32git restore $file
33echo "Created testdata.zip"
View as plain text