FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/cecli/tools/git_log.py at main · cecli-dev/cecli · GitHub
cecli-dev
cecli
Repository navigation
Code
Issues
12
(12)
Pull requests
7
(7)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cecli
/
cecli
/
tools
/
git_log.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (44 loc) · 1.53 KB
Breadcrumbs
cecli
/
cecli
/
tools
/
git_log.py
Copy path
File metadata and controls
49 lines (44 loc) · 1.53 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
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
=
"gitlog"
SCHEMA
=
{
"type"
:
"function"
,
"function"
: {
"name"
:
"GitLog"
,
"description"
:
"Show the git log."
,
"parameters"
: {
"type"
:
"object"
,
"properties"
: {
"limit"
: {
"type"
:
"integer"
,
"description"
:
"The maximum number of commits to show. Defaults to 10."
,
},
},
"required"
: [],
},
},
}
@
classmethod
def
execute
(
cls
,
coder
,
limit
=
10
,
**
kwargs
):
"""
Show the git log.
"""
response
=
ToolResponse
(
cls
.
NORM_NAME
)
if
not
coder
.
repo
:
response
.
append_result
(
"Not in a git repository."
)
return
response
try
:
commits
=
list
(
coder
.
repo
.
repo
.
iter_commits
(
max_count
=
limit
))
log_output
=
[]
for
commit
in
commits
:
short_hash
=
commit
.
hexsha
[:
8
]
message
=
commit
.
message
.
strip
().
split
(
"
\n
"
)[
0
]
log_output
.
append
(
f"
{
short_hash
}
{
message
}
"
)
response
.
append_result
(
"
\n
"
.
join
(
log_output
))
return
response
except
ANY_GIT_ERROR
as
e
:
coder
.
io
.
tool_error
(
f"Error running git log:
{
e
}
"
)
response
.
append_error
(
str
(
e
))
return
response
Back
|
FazBrowse Home
|
New Git URL