FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/cecli/tools/git_diff.py at main · cecli-dev/cecli · GitHub
cecli-dev
cecli
Repository navigation
Code
Issues
13
(13)
Pull requests
8
(8)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cecli
/
cecli
/
tools
/
git_diff.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (50 loc) · 1.79 KB
Breadcrumbs
cecli
/
cecli
/
tools
/
git_diff.py
Copy path
File metadata and controls
56 lines (50 loc) · 1.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from
cecli
.
repo
import
ANY_GIT_ERROR
from
cecli
.
tools
.
utils
.
base_tool
import
BaseTool
from
cecli
.
tools
.
utils
.
responses
import
ToolResponse
class
Tool
(
BaseTool
):
NORM_NAME
=
"gitdiff"
SCHEMA
=
{
"type"
:
"function"
,
"function"
: {
"name"
:
"GitDiff"
,
"description"
: (
"Show the diff between the current working directory and a git branch or commit."
),
"parameters"
: {
"type"
:
"object"
,
"properties"
: {
"branch"
: {
"type"
:
"string"
,
"description"
: (
"The branch or commit hash to diff against. Defaults to HEAD."
),
},
},
"required"
: [],
},
},
}
@
classmethod
def
execute
(
cls
,
coder
,
branch
=
None
,
**
kwargs
):
"""
Show the diff between the current working directory and a git branch or commit.
"""
response
=
ToolResponse
(
cls
.
NORM_NAME
)
if
not
coder
.
repo
:
response
.
append_result
(
"Not in a git repository."
)
return
response
try
:
if
branch
:
# Diff working tree against the requested branch/commit
diff
=
coder
.
repo
.
diff_commits
(
False
,
branch
,
None
)
else
:
diff
=
coder
.
repo
.
diff_commits
(
False
,
"HEAD"
,
None
)
if
not
diff
:
response
.
append_result
(
"No differences found."
)
return
response
response
.
append_result
(
diff
)
return
response
except
ANY_GIT_ERROR
as
e
:
coder
.
io
.
tool_error
(
f"Error running git diff:
{
e
}
"
)
response
.
append_error
(
str
(
e
))
return
response
Back
|
FazBrowse Home
|
New Git URL