您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

30 行
961 B

import json
import sys
import os
import re
def FailCommit(reason):
print("Oh no! Bad commit! "+reason)
sys.exit(1)
def GetStagedFileContent(filePath):
cmd = 'git show :' + filePath
stream = os.popen(cmd)
return stream.read()
def GetLFSStagedFileContent(filePath):
cmd = f"git cat-file blob :{filePath} | git lfs smudge"
stream = os.popen(cmd)
return stream.read()
output = GetStagedFileContent('Packages/manifest.json')
packages = json.loads(output)['dependencies']
if ('com.unity.multiplayer.virtualprojects' in packages):
FailCommit("Virtual projects in packages")
if ('github' in packages['com.unity.multiplayer.tools'].lower()):
FailCommit("Tools using github package")
content = GetLFSStagedFileContent('ProjectSettings/ProjectSettings.asset')
res = re.search(r'.*cloudProjectId:.*\w+\s*\n', content) != None
if res:
FailCommit("Detected cloud project id in project settings")