| 9 | |
| 10 | |
| 11 | class Add(GitSimBaseCommand): |
| 12 | def __init__(self, files: List[str]): |
| 13 | super().__init__() |
| 14 | self.hide_first_tag = True |
| 15 | self.allow_no_commits = True |
| 16 | self.files = files |
| 17 | settings.hide_merged_branches = True |
| 18 | self.n = self.n_default |
| 19 | |
| 20 | try: |
| 21 | self.selected_branches.append(self.repo.active_branch.name) |
| 22 | except TypeError: |
| 23 | pass |
| 24 | |
| 25 | for file in self.files: |
| 26 | if file not in [x.a_path for x in self.repo.index.diff(None)] + [ |
| 27 | z for z in self.repo.untracked_files |
| 28 | ]: |
| 29 | print(f"git-sim error: No modified file with name: '{file}'") |
| 30 | sys.exit() |
| 31 | |
| 32 | self.cmd += f"{type(self).__name__.lower()} {' '.join(self.files)}" |
| 33 | |
| 34 | def construct(self): |
| 35 | if not settings.stdout and not settings.output_only_path and not settings.quiet: |
| 36 | print(f"{settings.INFO_STRING} {self.cmd}") |
| 37 | |
| 38 | self.show_intro() |
| 39 | self.parse_commits() |
| 40 | self.recenter_frame() |
| 41 | self.scale_frame() |
| 42 | self.vsplit_frame() |
| 43 | self.setup_and_draw_zones() |
| 44 | self.show_command_as_title() |
| 45 | self.fadeout() |
| 46 | self.show_outro() |
| 47 | |
| 48 | def populate_zones( |
| 49 | self, |
| 50 | firstColumnFileNames, |
| 51 | secondColumnFileNames, |
| 52 | thirdColumnFileNames, |
| 53 | firstColumnArrowMap={}, |
| 54 | secondColumnArrowMap={}, |
| 55 | thirdColumnArrowMap={}, |
| 56 | ): |
| 57 | for x in self.repo.index.diff(None): |
| 58 | if "git-sim_media" not in x.a_path: |
| 59 | secondColumnFileNames.add(x.a_path) |
| 60 | for file in self.files: |
| 61 | if file == x.a_path: |
| 62 | thirdColumnFileNames.add(x.a_path) |
| 63 | secondColumnArrowMap[x.a_path] = m.Arrow( |
| 64 | stroke_width=3, color=self.fontColor |
| 65 | ) |
| 66 | try: |
| 67 | for y in self.repo.index.diff("HEAD"): |
| 68 | if "git-sim_media" not in y.a_path: |