【发布时间】:2019-06-10 07:16:13
【问题描述】:
我们如何实现服务器端挂钩或任何类似的解决方案,以限制 git push 进入 git 服务器?
例如,我们想要禁用包含 *.class 文件的提交的推送。
【问题讨论】:
-
服务钩子帮不了你,因为钩子是在代码被推送之后才开始的,你无法捕捉到之前的时刻。最好使用
.gitignore文件。
标签: git tfs azure-devops azure-repos
我们如何实现服务器端挂钩或任何类似的解决方案,以限制 git push 进入 git 服务器?
例如,我们想要禁用包含 *.class 文件的提交的推送。
【问题讨论】:
.gitignore 文件。
标签: git tfs azure-devops azure-repos
我不认为 Azure DevOps 使用钩子。
您可以使用Branch Policies 来使用外部验证服务(据我了解,这使用了网络挂钩)。
补充:this User Voice请求的状态表明以上为官方答复。
但也许最简单的情况是.gitignore 和代码审查?
【讨论】:
我所做的是将构建选项与 Azure DevOps 中的策略一起使用。这是我的azure-pipelines.yml 文件:
---
trigger:
branches:
exclude:
- '*'
pool:
vmImage: 'ubuntu-latest'
steps:
- script: sudo apt-get install python3-pip
displayName: 'Install Python PIP'
- script: sudo apt-get install python3-setuptools
condition: succeeded()
displayName: Install Python SetupTools
- script: sudo pip3 install -r requirements.txt
condition: succeeded()
displayName: Install Python PIP Packages
- task: PythonScript@0
inputs:
scriptSource: filePath
scriptPath: hooks/lint_checker.py
pythonInterpreter: python3
condition: succeeded()
displayName: Lint Checker
【讨论】: