MCPcopy
hub / github.com/initialcommit-com/git-sim / construct

Method construct

src/git_sim/rebase.py:36–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

34 self.cmd += f"{type(self).__name__.lower()} {self.branch}"
35
36 def construct(self):
37 if not settings.stdout and not settings.output_only_path and not settings.quiet:
38 print(f"{settings.INFO_STRING} {self.cmd}")
39
40 if self.branch in self.repo.git.branch(
41 "--contains", self.repo.active_branch.name
42 ):
43 print(
44 "git-sim error: Branch '"
45 + self.repo.active_branch.name
46 + "' is already included in the history of active branch '"
47 + self.branch
48 + "'."
49 )
50 sys.exit(1)
51
52 if self.repo.active_branch.name in self.repo.git.branch(
53 "--contains", self.branch
54 ):
55 print(
56 "git-sim error: Branch '"
57 + self.branch
58 + "' is already based on active branch '"
59 + self.repo.active_branch.name
60 + "'."
61 )
62 sys.exit(1)
63
64 self.show_intro()
65 branch_commit = self.get_commit(self.branch)
66 self.parse_commits(branch_commit)
67 head_commit = self.get_commit()
68
69 reached_base = False
70 for commit in self.get_default_commits():
71 if commit != "dark" and self.branch in self.repo.git.branch(
72 "--contains", commit
73 ):
74 reached_base = True
75
76 self.parse_commits(head_commit, shift=4 * m.DOWN)
77 self.parse_all()
78 self.center_frame_on_commit(branch_commit)
79
80 to_rebase = []
81 i = 0
82 current = head_commit
83 while self.branch not in self.repo.git.branch("--contains", current):
84 to_rebase.append(current)
85 i += 1
86 if i >= self.n:
87 break
88 current = self.get_default_commits()[i]
89
90 parent = branch_commit.hexsha
91
92 for j, tr in enumerate(reversed(to_rebase)):
93 if not reached_base and j == 0:

Callers

nothing calls this directly

Calls 15

setup_and_draw_parentMethod · 0.95
show_introMethod · 0.80
get_commitMethod · 0.80
parse_commitsMethod · 0.80
get_default_commitsMethod · 0.80
parse_allMethod · 0.80
recenter_frameMethod · 0.80
scale_frameMethod · 0.80
reset_head_branchMethod · 0.80
color_byMethod · 0.80

Tested by

no test coverage detected