Skip to content

Commit a60a576

Browse files
committed
feat: func level info
1 parent 9210c35 commit a60a576

4 files changed

Lines changed: 24 additions & 18 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM williamfzc/srctx:v0.2.1
1+
FROM williamfzc/srctx:v0.3.3
22

33
RUN apk add --no-cache python3 py3-pip
44

comment.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ def send_comment(token: str, repo_id: str, issue_number: int, content: str):
2626

2727

2828
def send_code_comments(
29-
token: str,
30-
commit_id: str,
31-
repo_id: str,
32-
issue_number: int,
33-
lines: typing.List[LineStat],
29+
token: str,
30+
commit_id: str,
31+
repo_id: str,
32+
issue_number: int,
33+
lines: typing.List[LineStat],
3434
):
3535
gg = Github3(token=token)
3636
owner, cur_repo = repo_id.split("/")
@@ -45,9 +45,12 @@ def send_code_comments(
4545
logger.info(
4646
f"leave comment in {each_line.fileName} L{each_line.lineNumber}"
4747
)
48-
pr.create_review_comment(
49-
f"[diffctx] cross file reference: {each_line.refScope.crossFileRefCount}",
50-
commit_id,
51-
each_line.fileName,
52-
each_line.lineNumber,
53-
)
48+
# todo: 443 failed
49+
# https://github.com/PyGithub/PyGithub/issues/2501
50+
51+
# pr.create_review_comment(
52+
# f"[diffctx] cross file reference: {each_line.refScope.crossFileRefCount}",
53+
# commit_id,
54+
# each_line.fileName,
55+
# each_line.lineNumber,
56+
# )

main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def process_with_ai(raw: str) -> str:
8080
- RefScope.TotalRefCount: total variable references in this line
8181
- RefScope.CrossFileRefCount: variable references by other files
8282
- RefScope.CrossDirRefCount: variable references by other directories
83+
- FuncRefScope.TotalFuncRefCount: total functions influenced by this line
84+
- FuncRefScope.CrossFuncFileRefCount: functions in other files influenced by this line
85+
- FUncRefScope.crossFuncDirRefCount: functions in other dirs influenced by this line
8386
8487
Here is a csv report below for a specific commit.
8588
Evaluate it and indicate the most important parts which reviewers should care.

object.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ class ReferenceScope(BaseModel):
66
crossFileRefCount: int
77
crossDirRefCount: int
88

9-
def is_safe(self):
10-
return (
11-
self.totalRefCount == 0
12-
and self.crossFileRefCount == 0
13-
and self.crossDirRefCount == 0
14-
)
9+
10+
class FuncReferenceScope(BaseModel):
11+
totalFuncRefCount: int
12+
crossFuncFileRefCount: int
13+
crossFuncDirRefCount: int
1514

1615

1716
class LineStat(BaseModel):
1817
fileName: str
1918
lineNumber: int
2019
refScope: ReferenceScope = Field(alias="ref")
20+
funcScope: FuncReferenceScope = Field(alias="funcRef")

0 commit comments

Comments
 (0)