Files
safeImport/script.sh

71 lines
3.1 KiB
Bash
Raw Normal View History

2025-08-07 15:35:07 +01:00
#!/bin/bash
2025-08-14 21:28:51 +01:00
# test repos
IGNORE_REPOS=("source-map-support" "jsdom" "eslint-utils" "polished" "webpack-bundle-analyzer" "jscodeshift" "chromium-bidi" "react-popper" "react-dropzone" "babel-plugin-styled-components" "unicode-trie" "relay-runtime" "react-element-to-jsx-string" "inline-style-prefixer" "karma" "cfb" "serve-handler") # Add the list of repositories to ignore
2025-08-07 15:35:07 +01:00
# set -e
2025-08-14 21:28:51 +01:00
function fail {
printf '%s\n' "$1" >&2 ## Send message to stderr.
exit "${2-1}" ## Return a code specified by $2, or 1 by default.
}
# rm -rf candidates
2025-08-07 15:35:07 +01:00
mkdir -p candidates
2025-08-14 21:28:51 +01:00
rm -iv processed.log current.log success.txt
2025-08-07 15:35:07 +01:00
# Read the minableRepositories2.csv file (rows of repo,test script). Read the repo and copy it from the `cache` folder`
while IFS=, read -r repo test_script; do
# Check if the repo is not empty
if [[ -n "$repo" ]]; then
# If the repo belongs to a given list, ignore it
if [[ " ${IGNORE_REPOS[@]} " =~ " ${repo} " ]]; then
echo "Ignoring repository: $repo"
continue
fi
# Extract the repo name from the URL
repo_name=$(basename "$repo" .git)
# Check if the repo directory exists in the cache folder
if [[ -d "../cache-repos/repos/$repo_name" ]]; then
echo "Processing repository: $repo_name"
2025-08-14 21:28:51 +01:00
echo "Processing repository: $repo_name" >> current.log
2025-08-07 15:35:07 +01:00
# Change to the repository directory
2025-08-14 21:28:51 +01:00
if [[ -d "candidates/$repo_name" ]]; then
echo "Repository $repo_name already exists in candidates, skipping..."
if [[ -f "candidates/$repo_name/.done" ]]; then
echo "Skipping $repo_name as it has already been processed."
continue
else
echo "Processing $repo_name again as .done file is missing. Run it again."
rm -rf "candidates/$repo_name"
fi
# Uncomment the next line if you want to remove the existing directory
# rm -rf "candidates/$repo_name"
else
cp -r "../cache-repos/repos/$repo_name" "candidates/$repo_name" || exit
pushd "candidates/$repo_name" > /dev/null || fail "Failed to pushd"
npm install --silent || fail "Failed to npm i"
popd > /dev/null || fail "Failed to popd"
2025-08-07 15:35:07 +01:00
2025-08-14 21:28:51 +01:00
node src/index.mjs "candidates/$repo_name" >> processed.log 2>&1
RESULT=$?
echo "--Separator-- $repo_name" >> processed.log
touch "candidates/$repo_name/.done"
if [[ $RESULT -ne 0 ]]; then
echo "Error processing repository: $repo_name"
# exit $RESULT
else
echo "$repo_name">> "success.txt"
fi
2025-08-07 15:35:07 +01:00
fi
# Change back to the original directory
else
echo "Repository $repo_name not found in cache" || exit 1
fi
2025-08-14 21:28:51 +01:00
else
echo "Skipping empty repository entry $repo";
2025-08-07 15:35:07 +01:00
fi
done < minableRepositories2.csv