deploy/kokoro.sh: improve

- Make a full clone so gendb can access commit history.

- Fix -repo flag to gendb.

- Comment.

Change-Id: I44f9e1217e27386460d372a5e2f3a8938d24b038
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/386694
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: kokoro <noreply+kokoro@google.com>
diff --git a/deploy/kokoro.sh b/deploy/kokoro.sh
index 378a02b..f2b7242 100755
--- a/deploy/kokoro.sh
+++ b/deploy/kokoro.sh
@@ -3,14 +3,29 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-set -e
+set -ex
 
+# Make a full clone of the repo so that gendb can find missing PublishDates in
+# reports by reading the commit history.
+#
+# Kokoro creates a shallow clone. Attempts to
+# deepen the clone with `git fetch --unshallow` failed,
+# apparently because Kokoro uses the `rpc:` scheme to
+# clone the repo.
+cd ..
+git clone https://go.googlesource.com/vulndb vulndb2
+cd vulndb2
+
+# Copy the existing vuln DB into a local directory so we can diff it.
 mkdir old-db
-gsutil -m cp -r gs://go-vulndb/* old-db
+gsutil -q -m cp -r gs://go-vulndb/* old-db
 
+# Generate a copy of the DB using the current state of the repo
+# and diff it with the old one. Do all this in a docker container
+# so we can select the version of Go that we want.
 docker run --rm \
-  -v $PWD:/vulndb \
-  -w /vulndb \
+  -v $PWD:/vulndb2 \
+  -w /vulndb2 \
   golang:1.17.3 \
-  /bin/bash -c 'go run ./cmd/gendb -repo /vulndb -out new-db &&
+  /bin/bash -c 'go run ./cmd/gendb -repo /vulndb2 -out new-db &&
                 go run ./cmd/dbdiff old-db new-db'