Skip to content

Commit 3a807bf

Browse files
Add command as title
Signed-off-by: Jacob Stopak <jacob@initialcommit.io>
1 parent 32a3a3f commit 3a807bf

24 files changed

+117
-61
lines changed

src/git_sim/add.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ def __init__(self, files: List[str]):
2929
print(f"git-sim error: No modified file with name: '{file}'")
3030
sys.exit()
3131

32+
self.cmd += f"{type(self).__name__.lower()} {' '.join(self.files)}"
33+
3234
def construct(self):
3335
if not settings.stdout and not settings.output_only_path and not settings.quiet:
34-
print(
35-
f"{settings.INFO_STRING} {type(self).__name__.lower()} {' '.join(self.files)}"
36-
)
36+
print(f"{settings.INFO_STRING} {self.cmd}")
3737

3838
self.show_intro()
3939
self.parse_commits()
4040
self.recenter_frame()
4141
self.scale_frame()
4242
self.vsplit_frame()
4343
self.setup_and_draw_zones()
44+
self.show_command_as_title()
4445
self.fadeout()
4546
self.show_outro()
4647

src/git_sim/branch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ class Branch(GitSimBaseCommand):
88
def __init__(self, name: str):
99
super().__init__()
1010
self.name = name
11+
self.cmd += f"{type(self).__name__.lower()} {self.name}"
1112

1213
def construct(self):
1314
if not settings.stdout and not settings.output_only_path and not settings.quiet:
14-
print(f"{settings.INFO_STRING} {type(self).__name__.lower()} {self.name}")
15+
print(f"{settings.INFO_STRING} {self.cmd}")
1516

1617
self.show_intro()
1718
self.parse_commits()
@@ -48,5 +49,6 @@ def construct(self):
4849
self.recenter_frame()
4950
self.scale_frame()
5051
self.color_by()
52+
self.show_command_as_title()
5153
self.fadeout()
5254
self.show_outro()

src/git_sim/checkout.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ def __init__(self, branch: str, b: bool):
6060
except TypeError:
6161
pass
6262

63+
self.cmd += (
64+
f"{type(self).__name__.lower()}{' -b' if self.b else ''} {self.branch}"
65+
)
66+
6367
def construct(self):
6468
if not settings.stdout and not settings.output_only_path and not settings.quiet:
65-
print(
66-
f"{settings.INFO_STRING } {type(self).__name__.lower()}{' -b' if self.b else ''} {self.branch}"
67-
)
69+
print(f"{settings.INFO_STRING} {self.cmd}")
6870

6971
self.show_intro()
7072
head_commit = self.get_commit()
@@ -118,4 +120,5 @@ def construct(self):
118120

119121
self.color_by()
120122
self.fadeout()
123+
self.show_command_as_title()
121124
self.show_outro()

src/git_sim/cherrypick.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ def __init__(self, commit: str, edit: str):
3131
except TypeError:
3232
pass
3333

34+
self.cmd += f"cherry-pick {self.commit}" + (
35+
(' -e "' + self.edit + '"') if self.edit else ""
36+
)
37+
3438
def construct(self):
3539
if not settings.stdout and not settings.output_only_path and not settings.quiet:
36-
print(
37-
f"{settings.INFO_STRING} cherry-pick {self.commit}"
38-
+ ((' -e "' + self.edit + '"') if self.edit else "")
39-
)
40+
print(f"{settings.INFO_STRING} {self.cmd}")
4041

4142
if self.repo.active_branch.name in self.repo.git.branch(
4243
"--contains", self.commit
@@ -66,5 +67,6 @@ def construct(self):
6667
self.scale_frame()
6768
self.reset_head_branch("abcdef")
6869
self.color_by(offset=2)
70+
self.show_command_as_title()
6971
self.fadeout()
7072
self.show_outro()

src/git_sim/clean.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ def __init__(self):
2121
except TypeError:
2222
pass
2323

24+
self.cmd += f"{type(self).__name__.lower()}"
25+
2426
def construct(self):
2527
if not settings.stdout and not settings.output_only_path and not settings.quiet:
26-
print(f"{settings.INFO_STRING} {type(self).__name__.lower()}")
28+
print(f"{settings.INFO_STRING} {self.cmd}")
2729

2830
self.show_intro()
2931
self.parse_commits()
@@ -35,6 +37,7 @@ def construct(self):
3537
second_column_name="----",
3638
third_column_name="Deleted files",
3739
)
40+
self.show_command_as_title()
3841
self.fadeout()
3942
self.show_outro()
4043

src/git_sim/clone.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ def __init__(self, url: str):
2323
super().__init__()
2424
self.url = url
2525
settings.max_branches_per_commit = 2
26+
self.cmd += f"{type(self).__name__.lower()} {self.url}"
2627

2728
def construct(self):
2829
if not settings.stdout and not settings.output_only_path and not settings.quiet:
29-
print(f"{settings.INFO_STRING } {type(self).__name__.lower()} {self.url}")
30+
print(f"{settings.INFO_STRING} {self.cmd}")
3031

3132
self.show_intro()
3233

@@ -58,6 +59,7 @@ def construct(self):
5859
self.scale_frame()
5960
self.add_details(repo_name)
6061
self.color_by()
62+
self.show_command_as_title()
6163
self.fadeout()
6264
self.show_outro()
6365

src/git_sim/commit.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ def __init__(self, message: str, amend: bool):
3030
)
3131
sys.exit(1)
3232

33+
self.cmd += (
34+
f"{type(self).__name__.lower()} {'--amend ' if self.amend else ''}"
35+
+ '-m "'
36+
+ self.message
37+
+ '"'
38+
)
39+
3340
def construct(self):
3441
if not settings.stdout and not settings.output_only_path and not settings.quiet:
35-
print(
36-
f"{settings.INFO_STRING } {type(self).__name__.lower()} {'--amend ' if self.amend else ''}"
37-
+ '-m "'
38-
+ self.message
39-
+ '"'
40-
)
42+
print(f"{settings.INFO_STRING} {self.cmd}")
4143

4244
self.show_intro()
4345
head_commit = self.get_commit()
@@ -77,6 +79,7 @@ def construct(self):
7779
third_column_name="New commit",
7880
)
7981

82+
self.show_command_as_title()
8083
self.fadeout()
8184
self.show_outro()
8285

src/git_sim/fetch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def __init__(self, remote: str, branch: str):
2424
print("git-sim error: no remote with name '" + self.remote + "'")
2525
sys.exit(1)
2626

27+
self.cmd += f"{type(self).__name__.lower()} {self.remote if self.remote else ''} {self.branch if self.branch else ''}"
28+
2729
def construct(self):
2830
if not settings.stdout and not settings.output_only_path and not settings.quiet:
29-
print(
30-
f"{settings.INFO_STRING } {type(self).__name__.lower()} {self.remote if self.remote else ''} {self.branch if self.branch else ''}"
31-
)
31+
print(f"{settings.INFO_STRING} {self.cmd}")
3232

3333
if not self.remote:
3434
self.remote = "origin"
@@ -79,6 +79,7 @@ def construct(self):
7979
self.recenter_frame()
8080
self.scale_frame()
8181
self.color_by()
82+
self.show_command_as_title()
8283
self.fadeout()
8384
self.show_outro()
8485
self.repo.git.clear_cache()

src/git_sim/git_sim_base_command.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
class GitSimBaseCommand(m.MovingCameraScene):
1919
def __init__(self):
2020
super().__init__()
21+
self.cmd = "git "
2122
self.init_repo()
2223

2324
self.font = settings.font
@@ -1295,6 +1296,28 @@ def add_group_to_author_groups(self, author, group):
12951296
else:
12961297
self.author_groups[author].append(group)
12971298

1299+
def show_command_as_title(self):
1300+
if True: # settings.show_command_as_title:
1301+
titleText = m.Text(
1302+
self.cmd,
1303+
font=self.font,
1304+
font_size=36,
1305+
color=self.fontColor,
1306+
)
1307+
titleText.move_to(
1308+
(
1309+
self.camera.frame.get_x(),
1310+
self.camera.frame.get_top()[1] - titleText.height * 1.5,
1311+
0,
1312+
)
1313+
)
1314+
ul = m.Underline(titleText)
1315+
if settings.animate:
1316+
self.play(m.AddTextLetterByLetter(titleText), m.Create(ul))
1317+
else:
1318+
self.add(titleText, ul)
1319+
self.toFadeOut.add(titleText, ul)
1320+
12981321
def del_rw(self, action, name, exc):
12991322
os.chmod(name, stat.S_IWRITE)
13001323
os.remove(name)

src/git_sim/log.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ def __init__(self, ctx: typer.Context, n: int, all: bool):
3232
except TypeError:
3333
pass
3434

35+
self.cmd += f"{type(self).__name__.lower()}{' --all' if self.all_subcommand else ''}{' -n ' + str(self.n) if self.n_subcommand else ''}"
36+
3537
def construct(self):
3638
if not settings.stdout and not settings.output_only_path and not settings.quiet:
37-
print(
38-
f"{settings.INFO_STRING} {type(self).__name__.lower()}{' --all' if self.all_subcommand else ''}{' -n ' + str(self.n) if self.n_subcommand else ''}"
39-
)
39+
print(f"{settings.INFO_STRING} {self.cmd}")
4040
self.show_intro()
4141
self.parse_commits()
4242
self.parse_all()
4343
self.recenter_frame()
4444
self.scale_frame()
4545
self.color_by()
46+
self.show_command_as_title()
4647
self.fadeout()
4748
self.show_outro()

0 commit comments

Comments
 (0)