1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#!/bin/bash -e
# Setup the repository and local system for development
cd "$(dirname "$0")/.."
rename_branch()
{
OLD=master
NEW=main
if git log $OLD >/dev/null 2>&1 &&
git remote get-url origin 2>&1 | grep fwupd/fwupd.git >/dev/null 2>&1; then
read -p "Rename existing $OLD branch to $NEW? (y/N) " question
if [ "$question" = "y" ]; then
git branch -m $OLD $NEW
git fetch origin
git branch -u origin/$NEW $NEW
git remote set-head origin -a
fi
fi
}
setup_git()
{
echo "Configuring git environment"
git config include.path ../.gitconfig
}
install_pip()
{
package=$1
python3 -m pip install $package
}
setup_precommit()
{
echo "Configuring pre-commit hooks"
python3 -m venv venv
source venv/bin/activate
install_pip pre-commit
pre-commit install
}
#always setup pre-commit
setup_precommit
#always setup git environment
setup_git
#if interactive
if [ -t 2 ]; then
rename_branch
fi
|