Skip to content

Added support for stash subcommands - push/pop/apply #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Usage: `git-sim commit -m "Commit message"`
![git-sim-commit_01-05-23_22-10-21](https://user-images.githubusercontent.com/49353917/210941149-d83677a1-3ab7-4880-bc0f-871b1f150087.jpg)

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

- Specify one or more `<file>` as a *modified* working directory file, or staged file
- If no `<file>` is specified, all available working directory and staged files will be included
Expand Down
150 changes: 103 additions & 47 deletions git_sim/git_sim_base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,15 @@ def setup_and_draw_zones(

firstColumnArrowMap = {}
secondColumnArrowMap = {}
thirdColumnArrowMap = {}

self.populate_zones(
firstColumnFileNames,
secondColumnFileNames,
thirdColumnFileNames,
firstColumnArrowMap,
secondColumnArrowMap,
thirdColumnArrowMap,
)

firstColumnFiles = m.VGroup()
Expand All @@ -608,53 +610,21 @@ def setup_and_draw_zones(
secondColumnFilesDict = {}
thirdColumnFilesDict = {}

for i, f in enumerate(firstColumnFileNames):
text = (
m.Text(
self.trim_path(f),
font="Monospace",
font_size=24,
color=self.fontColor,
)
.move_to(
(firstColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
)
.shift(m.DOWN * 0.5 * (i + 1))
)
firstColumnFiles.add(text)
firstColumnFilesDict[f] = text

for j, f in enumerate(secondColumnFileNames):
text = (
m.Text(
self.trim_path(f),
font="Monospace",
font_size=24,
color=self.fontColor,
)
.move_to(
(secondColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
)
.shift(m.DOWN * 0.5 * (j + 1))
)
secondColumnFiles.add(text)
secondColumnFilesDict[f] = text

for h, f in enumerate(thirdColumnFileNames):
text = (
m.Text(
self.trim_path(f),
font="Monospace",
font_size=24,
color=self.fontColor,
)
.move_to(
(thirdColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
)
.shift(m.DOWN * 0.5 * (h + 1))
)
thirdColumnFiles.add(text)
thirdColumnFilesDict[f] = text
self.create_zone_text(
firstColumnFileNames,
secondColumnFileNames,
thirdColumnFileNames,
firstColumnFiles,
secondColumnFiles,
thirdColumnFiles,
firstColumnFilesDict,
secondColumnFilesDict,
thirdColumnFilesDict,
firstColumnTitle,
secondColumnTitle,
thirdColumnTitle,
horizontal2,
)

if len(firstColumnFiles):
if settings.animate:
Expand Down Expand Up @@ -726,6 +696,26 @@ def setup_and_draw_zones(
self.add(secondColumnArrowMap[filename])
self.toFadeOut.add(secondColumnArrowMap[filename])

for filename in thirdColumnArrowMap:
thirdColumnArrowMap[filename].put_start_and_end_on(
(
thirdColumnFilesDict[filename].get_left()[0] - 0.25,
thirdColumnFilesDict[filename].get_left()[1],
0,
),
(
firstColumnFilesDict[filename].get_right()[0] + 0.25,
firstColumnFilesDict[filename].get_right()[1],
0,
),
)

if settings.animate:
self.play(m.Create(thirdColumnArrowMap[filename]))
else:
self.add(thirdColumnArrowMap[filename])
self.toFadeOut.add(thirdColumnArrowMap[filename])

self.toFadeOut.add(firstColumnFiles, secondColumnFiles, thirdColumnFiles)

def populate_zones(
Expand All @@ -735,6 +725,7 @@ def populate_zones(
thirdColumnFileNames,
firstColumnArrowMap={},
secondColumnArrowMap={},
thirdColumnArrowMap={},
):
for x in self.repo.index.diff(None):
if "git-sim_media" not in x.a_path:
Expand Down Expand Up @@ -946,6 +937,71 @@ def is_remote_tracking_branch(self, branch):
remote_tracking_branches[ref.name] = ref.commit.hexsha
return branch in remote_tracking_branches

def create_zone_text(
self,
firstColumnFileNames,
secondColumnFileNames,
thirdColumnFileNames,
firstColumnFiles,
secondColumnFiles,
thirdColumnFiles,
firstColumnFilesDict,
secondColumnFilesDict,
thirdColumnFilesDict,
firstColumnTitle,
secondColumnTitle,
thirdColumnTitle,
horizontal2,
):

for i, f in enumerate(firstColumnFileNames):
text = (
m.Text(
self.trim_path(f),
font="Monospace",
font_size=24,
color=self.fontColor,
)
.move_to(
(firstColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
)
.shift(m.DOWN * 0.5 * (i + 1))
)
firstColumnFiles.add(text)
firstColumnFilesDict[f] = text

for j, f in enumerate(secondColumnFileNames):
text = (
m.Text(
self.trim_path(f),
font="Monospace",
font_size=24,
color=self.fontColor,
)
.move_to(
(secondColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
)
.shift(m.DOWN * 0.5 * (j + 1))
)
secondColumnFiles.add(text)
secondColumnFilesDict[f] = text

for h, f in enumerate(thirdColumnFileNames):
text = (
m.Text(
self.trim_path(f),
font="Monospace",
font_size=24,
color=self.fontColor,
)
.move_to(
(thirdColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)
)
.shift(m.DOWN * 0.5 * (h + 1))
)
thirdColumnFiles.add(text)
thirdColumnFilesDict[f] = text


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