Skip to content

Commit

Permalink
Add package formatting pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
lubkoll committed Jul 29, 2024
1 parent f77df3c commit 864e36c
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions scripts/git/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ then
exit 1
fi

update_schemas_and_formatting() {
local contract=$1
if [[ $CHANGES == *contracts/${contract}* ]]
update_schemas() {
local workspace=$1
local contract=$2
if [[ $CHANGES == *${workspace}/contracts/${contract}* ]]
then
echo "Changes in ${contract} contract"
cd ${REPO_ROOT}/smart-contracts/osmosis/contracts/${contract}
cd ${REPO_ROOT}/smart-contracts/${workspace}/contracts/${contract}

# generate schemas
cargo schema
Expand All @@ -29,6 +30,15 @@ update_schemas_and_formatting() {
else
echo "No schema changes for ${contract}."
fi
fi
}

fix_formatting() {
local target=$1
if [[ $CHANGES == *${target}* ]]
then
echo "Changes in ${target}"
cd ${REPO_ROOT}/smart-contracts/${target}

# fix formatting
cargo fmt --all
Expand All @@ -38,9 +48,17 @@ update_schemas_and_formatting() {
fi
}

update_schemas_and_formatting lst-dex-adapter-osmosis
update_schemas_and_formatting dex-router-osmosis
update_schemas_and_formatting token-burner
update_schemas_and_formatting cl-vault
update_schemas_and_formatting merkle-incentives
update_schemas_and_formatting range-middleware
update_schemas osmosis lst-dex-adapter-osmosis
update_schemas osmosis dex-router-osmosis
update_schemas osmosis token-burner
update_schemas osmosis cl-vault
update_schemas osmosis merkle-incentives
update_schemas osmosis range-middleware
fix_formatting osmosis/contracts/lst-dex-adapter-osmosis
fix_formatting osmosis/contracts/dex-router-osmosis
fix_formatting osmosis/contracts/token-burner
fix_formatting osmosis/contracts/cl-vault
fix_formatting osmosis/contracts/merkle-incentives
fix_formatting osmosis/contracts/range-middleware
fix_formatting osmosis/packages/quasar-types
fix_formatting quasar/proto-build

0 comments on commit 864e36c

Please sign in to comment.