pre-commit

precommit配置:

  1. git clone https://github.com/alibaba/EasyNLP.git
  2. # 配置pre-commit(必选)
  3. sh tools/init.sh

commit

切换开发分支

配置完pre-commit之后才可以提交code commits,需要切换到分支开发

  1. # 使用自己的临时分支开发
  2. git branch your_branch
  3. git checkout your_branch
  4. # sync master
  5. git branch --set-upstream-to=origin your_branch
  6. git pull
  7. # 代码开发
  8. # xxx

Unit Test

开发完之后,建议跑一下unit tests

  1. # 代码开发完之后,需要跑一下unit tests
  2. cd tests/
  3. sh run_all_tests.sh
  4. cd ..

提交代码

  1. # add
  2. git add .
  3. # commit
  4. git commit -m 'your git commit message'
  5. # commit完之后会有信息显示,正常通过会有如下信息
  6. # Check for sensitive information leak:
  7. # Sensitive Information Leak Check Passed.
  8. # 代码检测失败则会有如下信息
  9. # Check for sensitive information leak:
  10. # Sensitive Information Leak Failed!
  11. # 确保commit成功之后可以提交pull request
  12. git push origin your_branch

提交结果如下所示:
image.png

提交pull request:最好在github页面上进入对应pull request,进行code reivew,通过后可以merge并且删除自己的开发分支。
image.png