-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit_pre_commit.sh
More file actions
executable file
·52 lines (46 loc) · 1.2 KB
/
git_pre_commit.sh
File metadata and controls
executable file
·52 lines (46 loc) · 1.2 KB
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
#!/bin/bash
gitroot=$(git rev-parse --show-toplevel)
echo git root dir found: $gitroot
cd $gitroot
#################### find src ####################
if [ $(basename $gitroot) == 'ipd' ]; then
ipd="$gitroot"
src=ipd
elif [ $(basename $gitroot) == 'rf2aa' ]; then
ipd="$gitroot/lib/ipd"
src=rf2aa
else
ipd="$gitroot/lib/ipd"
src='rf_diffusion'
fi
validate-pyproject pyproject.toml
#################### ruff ####################
echo running: ruff check --fix $src
if ruff check --fix $src; then
echo ruff ok;
else
echo ruff failed; exit 1;
fi
# #################### yapf ####################
# cmd="PYTHONPATH=$ipd python -m ipd code yapf $src"
# echo $cmd
# eval $cmd
# if [ $? == 0 ]; then
# echo files all formatted
# else
# echo yapf formatted some files, retry commit
# exit 1
# fi
# #################### pyright ####################
# if [ -f .pyright_hash_last_commit ]; then
# cmd="PYTHONPATH=$ipd python -m ipd code pyright $src --hashfile '.pyright_hash_last_commit'"
# echo $cmd
# eval $cmd
# if [ $? == 0 ]; then
# echo pyright pass
# else
# echo pyright fail
# exit 1
# fi
# git add .pyright_hash_last_commit
# fi