From d9f38826f7bb244ea4db20d4c5928fb5cde3a576 Mon Sep 17 00:00:00 2001 From: Esben Sparre Andreasen Date: Wed, 13 Oct 2021 20:43:17 +0200 Subject: [PATCH] Implement import-repositories.sh --- repo-tests/import-repositories.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 repo-tests/import-repositories.sh diff --git a/repo-tests/import-repositories.sh b/repo-tests/import-repositories.sh new file mode 100755 index 00000000000..eedf858ffe8 --- /dev/null +++ b/repo-tests/import-repositories.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e +set -x + +# commits relevant files from the selected repositories and stores the used commit sha in $repo.txt +repos="codeql-ruby codeql codeql-go" +for repo in $repos; do + echo "importing $repo" + rm -rf "$repo"; + git clone --depth 1 git@github.com:github/"$repo".git; + git -C "$repo" rev-parse HEAD > "$repo.txt"; + # remove upgrades and tests (heuristic) + find "$repo" -depth -type d \( -path "*/upgrades" -o -path "*/ql/test" \) -exec rm -rf {} \; ; + # only preserve files mentioned in tools/autobuild.sh + find "$repo" -type f -not \( -name "*.qll" -o -name "*.ql" -o -name "*.dbscheme" -o -name qlpack.yml \) -exec rm -f {} \; ; + # remove empty directories (git does not care though) + find "$repo" -type d -empty -delete; + git add "$repo" "$repo.txt"; + git commit -m "Add $repo sources ($(tr -d '\n' < $repo.txt))"; + echo "done" +done