FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/cecli/commands/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
/
commands
/
diff.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (55 loc) · 2.15 KB
Breadcrumbs
cecli
/
cecli
/
commands
/
diff.py
Copy path
File metadata and controls
69 lines (55 loc) · 2.15 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
57
58
59
60
61
62
63
64
65
66
67
68
69
from
typing
import
List
from
cecli
.
commands
.
utils
.
base_command
import
BaseCommand
from
cecli
.
repo
import
ANY_GIT_ERROR
from
cecli
.
run_cmd
import
run_cmd
class
DiffCommand
(
BaseCommand
):
NORM_NAME
=
"diff"
DESCRIPTION
=
"Display the diff of changes since the last message"
show_completion_notification
=
False
@
classmethod
async
def
execute
(
cls
,
io
,
coder
,
args
,
**
kwargs
):
try
:
await
cls
.
_raw_cmd_diff
(
io
,
coder
,
args
)
except
ANY_GIT_ERROR
as
err
:
io
.
tool_error
(
f"Unable to complete diff:
{
err
}
"
)
@
classmethod
async
def
_raw_cmd_diff
(
cls
,
io
,
coder
,
args
=
""
):
if
not
coder
.
repo
:
io
.
tool_error
(
"No git repository found."
)
return
current_head
=
coder
.
repo
.
get_head_commit_sha
()
if
current_head
is
None
:
io
.
tool_error
(
"Unable to get current commit. The repository might be empty."
)
return
if
len
(
coder
.
commit_before_message
)
<
2
:
commit_before_message
=
current_head
+
"^"
else
:
commit_before_message
=
coder
.
commit_before_message
[
-
2
]
if
not
commit_before_message
or
commit_before_message
==
current_head
:
io
.
tool_warning
(
"No changes to display since the last message."
)
return
io
.
tool_output
(
f"Diff since
{
commit_before_message
[:
7
]
}
..."
)
if
coder
.
pretty
:
run_cmd
(
f"git diff
{
commit_before_message
}
"
)
return
diff
=
coder
.
repo
.
diff_commits
(
coder
.
pretty
,
commit_before_message
,
"HEAD"
,
)
io
.
print
(
diff
)
@
classmethod
def
get_completions
(
cls
,
io
,
coder
,
args
)
->
List
[
str
]:
"""Get completion options for diff command."""
return
[]
@
classmethod
def
get_help
(
cls
)
->
str
:
"""Get help text for the diff command."""
help_text
=
super
().
get_help
()
help_text
+=
"
\n
Usage:
\n
"
help_text
+=
" /diff # Show changes since the last message
\n
"
help_text
+=
(
"
\n
Note: This shows git diff between the current state and the state before the last"
" message.
\n
"
)
return
help_text
Back
|
FazBrowse Home
|
New Git URL