diff --git a/key-words.md b/key-words.md
index 64b6dca..7e6f6c4 100755
--- a/key-words.md
+++ b/key-words.md
@@ -59,3 +59,5 @@ Pin Controllers (pinctrl)
Power Management
Memory Technology Devices (MTD)
Various
+## else
+mdadm
\ No newline at end of file
diff --git a/main.py b/main.py
index 6329cbc..47d2f05 100644
--- a/main.py
+++ b/main.py
@@ -6,12 +6,12 @@ if __name__=="__main__":
example_function()
repopath = "/home/qiurui/Documents/kernel/euler/kernel"
version_new = "f04289acdae57aa4066adee541dadd70b062ac88"
- version_old = "95982be1aa8140f22bbb90b0edf3e6644167f729"
+ version_old = "f075a16d45b1995e859c8d74493d4afa9bee7564"
source = "euler"
file_name = initmd(version_new,version_old,source)
print(file_name)
get_repo(repopath)
- count = get_commits_commit_count(version_new,version_old)
- hash_list = get_commit_hash(version_new,version_old)
+ count = get_commits_commit_count(version_old,version_new)
+ hash_list = get_commit_hash(version_old,version_new)
for hash in hash_list:
add_commit_info(file_name,hash)
diff --git a/pygitlog/bdanalysis.py b/pygitlog/bdanalysis.py
new file mode 100644
index 0000000..b0f4f61
--- /dev/null
+++ b/pygitlog/bdanalysis.py
@@ -0,0 +1,41 @@
+##对git日志的body进行解析
+import requests
+
+#获取kerywords的wiki url
+def get_wikipage(keywords):
+ if keywords == "md":
+ key = "mdadm"
+ elif keywords.startswith("PR"):
+ return ""
+ else:
+ key = keywords
+ S = requests.Session()
+ URL = "https://en.wikipedia.org/w/api.php"
+ PARAMS = {"action": "opensearch","namespace": "0","search": "","limit": "1","format": "json"}
+ PARAMS['search'] = key
+ R = S.get(url=URL, params=PARAMS)
+ DATA = R.json()
+ print(DATA)
+ print(DATA[3][0])
+ return DATA[3][0]
+
+#获取commit的关键词,如ext4
+def get_commit_kerywords(abbr):
+ print(abbr.split())
+ for abb in abbr.split():
+ if abb.endswith(":"):
+ keywords = abb.replace(':','')
+ for key in keywords.split('/'):
+ return "[" + key + "](" + get_wikipage(key) + ")"
+
+#获取commit的类型,如
+def get_commit_type(body):
+ for line in body:
+ #print(line)
+ if line.startswith("category"):
+ return line.replace('category:','')
+ else:
+ return ""
+
+def get_CVE_code(body):
+ return ""
\ No newline at end of file
diff --git a/pygitlog/example_module.py b/pygitlog/example_module.py
index 29b4629..c9c8a71 100644
--- a/pygitlog/example_module.py
+++ b/pygitlog/example_module.py
@@ -1,2 +1,3 @@
+##测试函数写法
def example_function():
print("Hello World! I bet you didn't expect that.")
\ No newline at end of file
diff --git a/pygitlog/gitoperation.py b/pygitlog/gitoperation.py
index cb9958c..b5bd04b 100644
--- a/pygitlog/gitoperation.py
+++ b/pygitlog/gitoperation.py
@@ -1,5 +1,5 @@
+##执行git操作并返回结果
import os
-import subprocess
#切换到工作目录
def get_repo(repopath):
@@ -47,6 +47,14 @@ def get_commit_email(hash):
process.close()
return preprocessed
+#获取某个commit的abbr
+def get_commit_abbr(hash):
+ cmd = "git log" + " " + hash + " -1 --pretty=format:'%s'"
+ process = os.popen(cmd)
+ preprocessed = process.read()
+ process.close()
+ return preprocessed
+
#获取某个commit的body
def get_commit_body(hash):
cmd = "git log" + " " + hash + " -1 --pretty=format:'%B'"
diff --git a/pygitlog/mdoperation.py b/pygitlog/mdoperation.py
index 794fbfb..88c60ef 100644
--- a/pygitlog/mdoperation.py
+++ b/pygitlog/mdoperation.py
@@ -1,5 +1,6 @@
+##markdown操作函数
from pygitlog.gitoperation import *
-import sys
+from pygitlog.bdanalysis import *
def mkdir(path):
# 去除首位空格
@@ -16,6 +17,7 @@ def mkdir(path):
# 如果目录存在则不创建,并提示目录已存在
print (path + " 目录已存在")
+#初始化kernel log summary的markdown文件
def initmd(version1,version2,source):
dir = os.getcwd() + "/output/"
mkdir(dir)
@@ -28,11 +30,10 @@ def initmd(version1,version2,source):
os.chmod(filename,448)
return filename
-
def format(str):
return str.replace('\n','
')
-#
+#参考格式
#| 2af9b20dbb39 | Sat Oct 28 08:15:07 2023 -1000 | Linus Torvalds | torvalds@linux-foundation.org
#| Merge tag 'x86-urgent-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc x86 fixes from Ingo Molnar
- Fix a possible CPU hotplug deadlock bug caused by the new TSC synchronization code
- Fix a legacy PIC discovery bug that results in device troubles on affected systems, such as non-working keybards, etc
- Add a new Intel CPU model number to
* tag 'x86-urgent-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/tsc: Defer marking TSC unstable to a worker
x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility
x86/cpu: Add model number for Intel Arrow Lake mobile processor
#| fix
add model| X86 CPU | arch/x86/include/asm/i8259.h
arch/x86/include/asm/intel-family.h
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/i8259.c
arch/x86/kernel/tsc_sync.c
@@ -43,7 +44,7 @@ def add_commit_info(filename,hash):
file.write("| " + get_commit_author(hash) + " ")
file.write("| " + get_commit_email(hash) + " ")
file.write("| " + format(get_commit_body(hash)) + " ")
- file.write("| fix
add model
")
- file.write("| fix
add model
")
+ file.write("| " + get_commit_type(get_commit_body(hash)) + "
")
+ file.write("| " + get_commit_kerywords(get_commit_abbr(hash)) + "
")
file.write("| " + format(get_commit_diff_files(hash)) + " |\n")
file.close()
\ No newline at end of file
diff --git a/test/test_wikiapi.py b/test/test_wikiapi.py
new file mode 100644
index 0000000..2dbf45a
--- /dev/null
+++ b/test/test_wikiapi.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python3
+
+"""
+ opensearch.py
+ MediaWiki API Demos
+ Demo of `Opensearch` module: Search the wiki and obtain
+ results in an OpenSearch (http://www.opensearch.org) format
+ MIT License
+"""
+
+import requests
+
+S = requests.Session()
+
+URL = "https://en.wikipedia.org/w/api.php"
+
+keywords = ""
+
+PARAMS = {"action": "opensearch","namespace": "0","search": "","limit": "1","format": "json"}
+PARAMS['search'] = keywords
+
+#PARAMS = {"action": "opensearch","namespace": "0","search": "mdadm","limit": "1","format": "json"}
+R = S.get(url=URL, params=PARAMS)
+DATA = R.json()
+
+print(DATA[3][0])
\ No newline at end of file