Skip to content

Commit 915fbbe

Browse files
Add support for stash subcommands push/pop/apply (#60)
Signed-off-by: Abhijit Nathwani <abhijit.nathwani@gmail.com>
1 parent 533e365 commit 915fbbe

File tree

3 files changed

+242
-78
lines changed

3 files changed

+242
-78
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Usage: `git-sim commit -m "Commit message"`
186186
![git-sim-commit_01-05-23_22-10-21](https://user-images.githubusercontent.com/49353917/210941149-d83677a1-3ab7-4880-bc0f-871b1f150087.jpg)
187187

188188
### git stash
189-
Usage: `git-sim stash <file>`
189+
Usage: `git-sim stash [push|pop|apply] <file>`
190190

191191
- Specify one or more `<file>` as a *modified* working directory file, or staged file
192192
- If no `<file>` is specified, all available working directory and staged files will be included

git_sim/git_sim_base_command.py

Lines changed: 103 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,15 @@ def setup_and_draw_zones(
591591

592592
firstColumnArrowMap = {}
593593
secondColumnArrowMap = {}
594+
thirdColumnArrowMap = {}
594595

595596
self.populate_zones(
596597
firstColumnFileNames,
597598
secondColumnFileNames,
598599
thirdColumnFileNames,
599600
firstColumnArrowMap,
600601
secondColumnArrowMap,
602+
thirdColumnArrowMap,
601603
)
602604

603605
firstColumnFiles = m.VGroup()
@@ -608,53 +610,21 @@ def setup_and_draw_zones(
608610
secondColumnFilesDict = {}
609611
thirdColumnFilesDict = {}
610612

611-
for i, f in enumerate(firstColumnFileNames):
612-
text = (
613-
m.Text(
614-
self.trim_path(f),
615-
font="Monospace",
616-
font_size=24,
617-
color=self.fontColor,
618-
)
619-
.move_to(
620-
(firstColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
621-
)
622-
.shift(m.DOWN * 0.5 * (i + 1))
623-
)
624-
firstColumnFiles.add(text)
625-
firstColumnFilesDict[f] = text
626-
627-
for j, f in enumerate(secondColumnFileNames):
628-
text = (
629-
m.Text(
630-
self.trim_path(f),
631-
font="Monospace",
632-
font_size=24,
633-
color=self.fontColor,
634-
)
635-
.move_to(
636-
(secondColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
637-
)
638-
.shift(m.DOWN * 0.5 * (j + 1))
639-
)
640-
secondColumnFiles.add(text)
641-
secondColumnFilesDict[f] = text
642-
643-
for h, f in enumerate(thirdColumnFileNames):
644-
text = (
645-
m.Text(
646-
self.trim_path(f),
647-
font="Monospace",
648-
font_size=24,
649-
color=self.fontColor,
650-
)
651-
.move_to(
652-
(thirdColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
653-
)
654-
.shift(m.DOWN * 0.5 * (h + 1))
655-
)
656-
thirdColumnFiles.add(text)
657-
thirdColumnFilesDict[f] = text
613+
self.create_zone_text(
614+
firstColumnFileNames,
615+
secondColumnFileNames,
616+
thirdColumnFileNames,
617+
firstColumnFiles,
618+
secondColumnFiles,
619+
thirdColumnFiles,
620+
firstColumnFilesDict,
621+
secondColumnFilesDict,
622+
thirdColumnFilesDict,
623+
firstColumnTitle,
624+
secondColumnTitle,
625+
thirdColumnTitle,
626+
horizontal2,
627+
)
658628

659629
if len(firstColumnFiles):
660630
if settings.animate:
@@ -726,6 +696,26 @@ def setup_and_draw_zones(
726696
self.add(secondColumnArrowMap[filename])
727697
self.toFadeOut.add(secondColumnArrowMap[filename])
728698

699+
for filename in thirdColumnArrowMap:
700+
thirdColumnArrowMap[filename].put_start_and_end_on(
701+
(
702+
thirdColumnFilesDict[filename].get_left()[0] - 0.25,
703+
thirdColumnFilesDict[filename].get_left()[1],
704+
0,
705+
),
706+
(
707+
firstColumnFilesDict[filename].get_right()[0] + 0.25,
708+
firstColumnFilesDict[filename].get_right()[1],
709+
0,
710+
),
711+
)
712+
713+
if settings.animate:
714+
self.play(m.Create(thirdColumnArrowMap[filename]))
715+
else:
716+
self.add(thirdColumnArrowMap[filename])
717+
self.toFadeOut.add(thirdColumnArrowMap[filename])
718+
729719
self.toFadeOut.add(firstColumnFiles, secondColumnFiles, thirdColumnFiles)
730720

731721
def populate_zones(
@@ -735,6 +725,7 @@ def populate_zones(
735725
thirdColumnFileNames,
736726
firstColumnArrowMap={},
737727
secondColumnArrowMap={},
728+
thirdColumnArrowMap={},
738729
):
739730
for x in self.repo.index.diff(None):
740731
if "git-sim_media" not in x.a_path:
@@ -946,6 +937,71 @@ def is_remote_tracking_branch(self, branch):
946937
remote_tracking_branches[ref.name] = ref.commit.hexsha
947938
return branch in remote_tracking_branches
948939

940+
def create_zone_text(
941+
self,
942+
firstColumnFileNames,
943+
secondColumnFileNames,
944+
thirdColumnFileNames,
945+
firstColumnFiles,
946+
secondColumnFiles,
947+
thirdColumnFiles,
948+
firstColumnFilesDict,
949+
secondColumnFilesDict,
950+
thirdColumnFilesDict,
951+
firstColumnTitle,
952+
secondColumnTitle,
953+
thirdColumnTitle,
954+
horizontal2,
955+
):
956+
957+
for i, f in enumerate(firstColumnFileNames):
958+
text = (
959+
m.Text(
960+
self.trim_path(f),
961+
font="Monospace",
962+
font_size=24,
963+
color=self.fontColor,
964+
)
965+
.move_to(
966+
(firstColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
967+
)
968+
.shift(m.DOWN * 0.5 * (i + 1))
969+
)
970+
firstColumnFiles.add(text)
971+
firstColumnFilesDict[f] = text
972+
973+
for j, f in enumerate(secondColumnFileNames):
974+
text = (
975+
m.Text(
976+
self.trim_path(f),
977+
font="Monospace",
978+
font_size=24,
979+
color=self.fontColor,
980+
)
981+
.move_to(
982+
(secondColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
983+
)
984+
.shift(m.DOWN * 0.5 * (j + 1))
985+
)
986+
secondColumnFiles.add(text)
987+
secondColumnFilesDict[f] = text
988+
989+
for h, f in enumerate(thirdColumnFileNames):
990+
text = (
991+
m.Text(
992+
self.trim_path(f),
993+
font="Monospace",
994+
font_size=24,
995+
color=self.fontColor,
996+
)
997+
.move_to(
998+
(thirdColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
999+
)
1000+
.shift(m.DOWN * 0.5 * (h + 1))
1001+
)
1002+
thirdColumnFiles.add(text)
1003+
thirdColumnFilesDict[f] = text
1004+
9491005

9501006
class DottedLine(m.Line):
9511007
def __init__(self, *args, dot_spacing=0.4, dot_kwargs={}, **kwargs):

0 commit comments

Comments
 (0)