Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.png filter=lfs diff=lfs merge=lfs -text
1 change: 0 additions & 1 deletion CHANGELOG.md

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
English | [中文](README.zh_CN.md)

# tRPC-Go Framework
# tRPC-Go framework

[![Go Reference](https://pkg.go.dev/badge/github.com/trpc-group/trpc-go.svg)](https://pkg.go.dev/github.com/trpc-group/trpc-go)
[![Go Report Card](https://goreportcard.com/badge/trpc.group/trpc-go/trpc-go)](https://goreportcard.com/report/trpc.group/trpc-go/trpc-go)
Expand Down
57 changes: 57 additions & 0 deletions add_copyright.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
import os
import re

COPYRIGHT_HEADER = '''//
//
// Tencent is pleased to support the open source community by making tRPC available.
//
// Copyright (C) 2023 THL A29 Limited, a Tencent company.
// All rights reserved.
//
// If you have downloaded a copy of the tRPC source code from Tencent,
// please note that tRPC source code is licensed under the Apache 2.0 License,
// A copy of the Apache 2.0 License is included in this file.
//
//
'''

def has_copyright_header(content):
# 检查文件是否已经包含版权声明
return COPYRIGHT_HEADER.strip() in content

def add_copyright_header(file_path):
try:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()

if has_copyright_header(content):
print(f"File {file_path} already has copyright header")
return False

# 添加版权声明
with open(file_path, 'w', encoding='utf-8') as f:
f.write(COPYRIGHT_HEADER + content)

print(f"Added copyright header to {file_path}")
return True
except Exception as e:
print(f"Error processing {file_path}: {str(e)}")
return False

def process_directory(directory):
modified_files = 0
for root, _, files in os.walk(directory):
for file in files:
if file.endswith('.go'):
file_path = os.path.join(root, file)
if add_copyright_header(file_path):
modified_files += 1

return modified_files

if __name__ == '__main__':
current_dir = os.getcwd()
print(f"Processing directory: {current_dir}")
modified = process_directory(current_dir)
print(f"\nTotal files modified: {modified}")
43 changes: 43 additions & 0 deletions add_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os

# 定义要添加的文本
HEADER_TEXT = """//
//
// Tencent is pleased to support the open source community by making tRPC available.
//
// Copyright (C) 2023 THL A29 Limited, a Tencent company.
// All rights reserved.
//
// If you have downloaded a copy of the tRPC source code from Tencent,
// please note that tRPC source code is licensed under the Apache 2.0 License,
// A copy of the Apache 2.0 License is included in this file.
//
//

"""

# 定义需要处理的文件扩展名
ALLOWED_EXTENSIONS = {'.go', '.proto'}

# 递归遍历目录及其子目录
def process_directory(directory):
for root, _, files in os.walk(directory):
for filename in files:
# 检查文件扩展名是否符合要求
if os.path.splitext(filename)[1] in ALLOWED_EXTENSIONS:
file_path = os.path.join(root, filename)
# 读取文件内容
with open(file_path, 'r') as file:
content = file.read()

# 检查文件开头是否已经包含 HEADER_TEXT
if not content.startswith(HEADER_TEXT):
# 将 HEADER_TEXT 添加到文件开头
with open(file_path, 'w') as file:
file.write(HEADER_TEXT + content)
print(f"Header added to: {file_path}")
else:
print(f"Header already exists in: {file_path}")

# 从当前目录开始处理
process_directory('.')
Loading