forked from initialcommit-com/git-sim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_sim_add.py
More file actions
63 lines (52 loc) · 2.32 KB
/
git_sim_add.py
File metadata and controls
63 lines (52 loc) · 2.32 KB
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
import sys
import git
import manim as m
from git_sim.git_sim_base_command import GitSimBaseCommand
class GitSimAdd(GitSimBaseCommand):
def __init__(self, scene):
super().__init__(scene)
self.maxrefs = 2
self.hide_first_tag = True
self.allow_no_commits = True
try:
self.selected_branches.append(self.repo.active_branch.name)
except TypeError:
pass
for name in self.scene.args.name:
if name not in [x.a_path for x in self.repo.index.diff(None)] + [z for z in self.repo.untracked_files]:
print("git-sim error: No modified file with name: '" + name + "'")
sys.exit()
def execute(self):
print("Simulating: git " + self.scene.args.subcommand + " " + " ".join(self.scene.args.name))
self.show_intro()
self.get_commits()
self.parse_commits(self.commits[0])
self.recenter_frame()
self.scale_frame()
self.vsplit_frame()
self.setup_and_draw_zones()
self.fadeout()
self.show_outro()
def populate_zones(self, firstColumnFileNames, secondColumnFileNames, thirdColumnFileNames, firstColumnArrowMap, secondColumnArrowMap):
for x in self.repo.index.diff(None):
if "git-sim_media" not in x.a_path:
secondColumnFileNames.add(x.a_path)
for name in self.scene.args.name:
if name == x.a_path:
thirdColumnFileNames.add(x.a_path)
secondColumnArrowMap[x.a_path] = m.Arrow(stroke_width=3, color=self.scene.fontColor)
try:
for y in self.repo.index.diff("HEAD"):
if "git-sim_media" not in y.a_path:
thirdColumnFileNames.add(y.a_path)
except git.exc.BadName:
for (y, _stage), entry in self.repo.index.entries.items():
if "git-sim_media" not in y:
thirdColumnFileNames.add(y)
for z in self.repo.untracked_files:
if "git-sim_media" not in z:
firstColumnFileNames.add(z)
for name in self.scene.args.name:
if name == z:
thirdColumnFileNames.add(z)
firstColumnArrowMap[z] = m.Arrow(stroke_width=3, color=self.scene.fontColor)