packages/getmergebase.sh
Gabriel Huber 44e7ea517b
Implement new package scanner (#2532)
* Implement new package scanner

* Replace hardcoded repository paths in getmergebase.sh

* Create branch instead of working on detached head in getmergebase.sh

* Checkout with unlimited depth

* Fix package_scanner command line

* Merge new package scanner

* Improve debug information of germergebase.sh

* Remove validate_json.js as package_scanner already validates json

* Improve documentation of getmergebase.sh

* Close http client at the end of the program

* Address code review comments

* Fix normalization of aliases
2023-03-14 10:40:45 +08:00

28 lines
1022 B
Bash
Executable File

#!/bin/bash
# CI helper script to checkout the current packages.json and
# the version at the merge base to compare to.
set -e
# Repository and branch the PR will be merged into
targetRepository="https://github.com/$GITHUB_REPOSITORY"
targetBranch="$GITHUB_BASE_REF"
# Create a branch of the current repository state because actions/checkout
# leaves us with a detached HEAD
git branch merge-branch
# Backup the current packages.json because it will get overwritten by a
# checkout
cp packages.json packages.json.bak
# Fetch the merge target branch into a branch called "base"
git fetch "$targetRepository" "$targetBranch:base"
# Determine the last common commit (the merge base)
mergeBase="$(git merge-base merge-branch base)"
echo "Comparing against packages.json at $mergeBase"
# Checkout the package list at the branching point
git checkout "$mergeBase" packages.json
# PR version becomes packages.json and merge base becomes packages_old.json
mv packages.json packages_old.json
mv packages.json.bak packages.json