Skip to content

Commit b3c0ad7

Browse files
Fix add subcommand for empty repos with no commits
Signed-off-by: Jacob Stopak <jacob@initialcommit.io>
1 parent 3a807bf commit b3c0ad7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/git_sim/git_sim_base_command.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ def parse_commits(
117117
shift=numpy.array([0.0, 0.0, 0.0]),
118118
make_branches_remote=False,
119119
):
120+
if not self.head_exists():
121+
commit = self.create_dark_commit()
122+
120123
commit = commit or self.get_commit()
121124

122125
if commit != "dark":
@@ -642,6 +645,9 @@ def setup_and_draw_zones(
642645
third_column_name="Staging area",
643646
reverse=False,
644647
):
648+
if self.check_all_dark():
649+
self.zone_title_offset = 2.0 if platform.system() == "Windows" else 6.0
650+
645651
horizontal = m.Line(
646652
(
647653
self.camera.frame.get_left()[0],
@@ -1322,6 +1328,18 @@ def del_rw(self, action, name, exc):
13221328
os.chmod(name, stat.S_IWRITE)
13231329
os.remove(name)
13241330

1331+
def head_exists(self):
1332+
try:
1333+
hc = self.repo.head.commit
1334+
except ValueError:
1335+
return False
1336+
return True
1337+
1338+
def check_all_dark(self):
1339+
if not self.drawnCommits:
1340+
return True
1341+
return False
1342+
13251343

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

0 commit comments

Comments
 (0)