year преди 2 месеца
родител
ревизия
9101bc4cbd
променени са 2 файла, в които са добавени 14 реда и са изтрити 7 реда
  1. 2 1
      package.json
  2. 12 6
      statics.py

+ 2 - 1
package.json

@@ -19,7 +19,8 @@
     "build:br": "node scripts/swEnv.js .env.br .env.local  && next build",
     "start": "next start",
     "lint": "next lint",
-    "build": "next build"
+    "build": "next build",
+    "statics": "python ./statics.py"
   },
   "dependencies": {
     "@lucky-canvas/react": "^0.1.13",

+ 12 - 6
statics.py

@@ -62,14 +62,17 @@ def count_changes_in_commit(repo_path, commit_hash):
         
         insertions = 0
         deletions = 0
+        totals=0
         for line in result.stdout.strip().split('\n'):
             parts = line.split('\t')
+            
             if len(parts) == 3:
-                ins, dels, _ = parts
+                ins, dels, total = parts
                 insertions += int(ins) if ins != '-' else 0
                 deletions += int(dels) if dels != '-' else 0
+                totals += 1
         
-        return insertions, deletions
+        return insertions, deletions,totals
     except subprocess.CalledProcessError:
         return 0, 0
 
@@ -117,13 +120,15 @@ def main():
     # 统计总变动
     total_insertions = 0
     total_deletions = 0
+    total_files = 0
     filetype_stats = defaultdict(lambda: {"insertions": 0, "deletions": 0})
     
     for commit in commits:
         # 统计总变动
-        ins, dels = count_changes_in_commit(repo_path, commit)
+        ins, dels, totals= count_changes_in_commit(repo_path, commit)
         total_insertions += ins
         total_deletions += dels
+        total_files += totals
         
         # 按文件类型统计
         commit_filetype_stats = count_changes_by_filetype(repo_path, commit)
@@ -135,9 +140,10 @@ def main():
     print(f"Git仓库代码变动统计-{repo_name}-{branch_name}")
     print(f"日期: {datetime.date.today()}")
     print(f"提交数: {len(commits)}")
-    print(f"总插入行数: {total_insertions}")
-    print(f"总删除行数: {total_deletions}")
-    print(f"净变动行数: {total_insertions - total_deletions}")
+    print(f"总行数: {total_insertions}")
+    print(f"总文件数: {total_files}")
+    # print(f"总删除行数: {total_deletions}")
+    # print(f"净变动行数: {total_insertions - total_deletions}")
     print("\n按文件类型统计:")
     print("{:<10} {:>12} {:>12} {:>12}".format("类型", "插入", "删除", "净变动"))
     print("-" * 48)