deepspeed

Форк
0
/
check-license.py 
48 строк · 1.3 Кб
1
#!/usr/bin/env python3
2
# Copyright (c) Microsoft Corporation.
3
# SPDX-License-Identifier: Apache-2.0
4

5
# DeepSpeed Team
6

7
from __future__ import annotations
8
'''Copyright The Microsoft DeepSpeed Team'''
9
"""
10
Modified from https://github.com/jlebar/pre-commit-hooks/blob/master/check_do_not_submit.py
11
"""
12

13
import subprocess
14
import sys
15

16

17
def err(s: str) -> None:
18
    print(s, file=sys.stderr)
19

20

21
COPYRIGHT = [
22
    (r"^# Copyright (c) Microsoft Corporation.$", r"^\/\/ Copyright (c) Microsoft Corporation.$"),
23
    (r"^# SPDX-License-Identifier: Apache-2.0$", r"^\/\/ SPDX-License-Identifier: Apache-2.0$"),
24
    (r"^# DeepSpeed Team$", r"^\/\/ DeepSpeed Team$"),
25
]
26

27
success = True
28
failures = []
29
for f in sys.argv[1:]:
30
    for copyright_line in COPYRIGHT:
31
        cmd = ["git", "grep", "--quiet"]
32
        for line in copyright_line:
33
            cmd.extend(["-e", line])
34
        cmd.append(f)
35
        res = subprocess.run(cmd, capture_output=True)
36
        if res.returncode == 1:
37
            success = False
38
            failures.append(f)
39
            break
40
        elif res.returncode == 2:
41
            err(f"Error invoking grep on {', '.join(sys.argv[1:])}:")
42
            err(res.stderr.decode("utf-8"))
43
            sys.exit(2)
44

45
if not success:
46
    err(f'{failures}: Missing license at top of file')
47
    err(res.stdout.decode("utf-8"))
48
    sys.exit(1)
49

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.