Skip to content

Commit

Permalink
feat: last update before ppatch-next
Browse files Browse the repository at this point in the history
Signed-off-by: jingfelix <[email protected]>
  • Loading branch information
jingfelix committed Aug 25, 2024
1 parent 8ac99eb commit 95d4dc2
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 122 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/python/black
rev: 23.11.0
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pdm-project/pdm
rev: 2.11.1
rev: 2.17.3
hooks:
- id: pdm-export
args: ['-o', 'requirements.txt', '--without-hashes']
Expand Down
210 changes: 116 additions & 94 deletions pdm.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies = [
"pydantic-settings>=2.2.1",
"cscopy>=0.0.1",
"whatthepatch-pydantic==1.0.6a1",
"structlog>=24.2.0",
]
requires-python = ">=3.10"
readme = "README.md"
Expand Down
20 changes: 11 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# This file is @generated by PDM.
# Please do not edit it manually.

annotated-types==0.6.0
annotated-types==0.7.0
click==8.1.7
colorama==0.4.6
colorama==0.4.6; platform_system == "Windows"
cscopy==0.0.1
markdown-it-py==3.0.0
mdurl==0.1.2
objprint==0.2.3
pydantic==2.7.4
pydantic-core==2.18.4
pydantic-settings==2.2.1
pygments==2.17.2
pydantic==2.8.2
pydantic-core==2.20.1
pydantic-settings==2.4.0
pygments==2.18.0
python-dotenv==1.0.1
rich==13.7.0
rich==13.7.1
shellingham==1.5.4
typer==0.9.0
typing-extensions==4.9.0
structlog==24.4.0
typer==0.12.3
typer[all]==0.12.3
typing-extensions==4.12.2
viztracer==0.16.3
whatthepatch-pydantic==1.0.6a1
13 changes: 6 additions & 7 deletions src/ppatch/commands/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ def getsymbol(files: list[str], symbols: list[str]):

# 之后还是要按 patch/file/hunk 划分的,这里只是一个临时的 command
# 解析的思路:先按文件划分,再按每个 hunk 划分
# 现在需要做的:增强 ppatch 的补丁解析功能,使其能够解析出 diff-hunk-change 三层结构
# DONE 现在需要做的:增强 ppatch 的补丁解析功能,使其能够解析出 diff-hunk-change 三层结构

for symbol in symbols:
with CscopeWorkspace(files, cli) as workspace:
for symbol in symbols:
result = workspace.search_c_symbol(symbol)
with CscopeWorkspace(files, cli) as workspace:
for symbol in symbols:
result = workspace.search_c_symbol(symbol)

for res in result:
logger.info(f"{res.file}:{res.line} {res.content}")
for res in result:
logger.info(f"{res.file}:{res.line} {res.content}")
10 changes: 5 additions & 5 deletions src/ppatch/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class Diff(WTPDiff):


class Patch(BaseModel):
sha: str
author: str
date: str
subject: str
message: str
sha: str | None
author: str | None
date: str | None
subject: str | None
message: str | None
diff: list[Diff] | list[WTPDiff] = [] # 临时的兼容方案


Expand Down
7 changes: 4 additions & 3 deletions src/ppatch/utils/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ def parse_patch(text: str) -> Patch:
idx = i
break
else:
raise ValueError(
"No diff --git line found, check if the input is a valid patch"
)
# raise ValueError(
# "No diff --git line found, check if the input is a valid patch"
# )
idx = len(lines) + 1

git_message_lines: list[str] = []
if idx == 0:
Expand Down

0 comments on commit 95d4dc2

Please sign in to comment.