get keywords from commit abstract and get wikipage
This commit is contained in:
parent
198d363b8c
commit
552c94fa71
|
@ -59,3 +59,5 @@ Pin Controllers (pinctrl)
|
|||
Power Management
|
||||
Memory Technology Devices (MTD)
|
||||
Various
|
||||
## else
|
||||
mdadm
|
6
main.py
6
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)
|
||||
|
|
|
@ -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 ""
|
|
@ -1,2 +1,3 @@
|
|||
##测试函数写法
|
||||
def example_function():
|
||||
print("Hello World! I bet you didn't expect that.")
|
|
@ -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'"
|
||||
|
|
|
@ -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','<br>')
|
||||
|
||||
#
|
||||
#参考格式
|
||||
#| 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<br> Pull misc x86 fixes from Ingo Molnar<br> - Fix a possible CPU hotplug deadlock bug caused by the new TSC synchronization code<br> - Fix a legacy PIC discovery bug that results in device troubles on affected systems, such as non-working keybards, etc<br> - Add a new Intel CPU model number to <asm/intel-family.h><br> * tag 'x86-urgent-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:<br>  x86/tsc: Defer marking TSC unstable to a worker<br>  x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility<br>  x86/cpu: Add model number for Intel Arrow Lake mobile processor
|
||||
#| fix<br> add model| X86 CPU | arch/x86/include/asm/i8259.h<br> arch/x86/include/asm/intel-family.h<br> arch/x86/kernel/acpi/boot.c<br> arch/x86/kernel/i8259.c<br> arch/x86/kernel/tsc_sync.c<br>
|
||||
|
@ -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<br>add model<br> ")
|
||||
file.write("| fix<br>add model<br> ")
|
||||
file.write("| " + get_commit_type(get_commit_body(hash)) + "<br> ")
|
||||
file.write("| " + get_commit_kerywords(get_commit_abbr(hash)) + "<br> ")
|
||||
file.write("| " + format(get_commit_diff_files(hash)) + " |\n")
|
||||
file.close()
|
|
@ -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])
|
Loading…
Reference in New Issue