File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -166,8 +166,14 @@ def git_cli(self) -> GitCLI:
166166 return git_cli
167167
168168 @property
169- def head_commit (self ) -> GitCommit :
170- return self .git_cli .head .commit
169+ def head_commit (self ) -> GitCommit | None :
170+ try :
171+ return self .git_cli .head .commit
172+ except ValueError as e :
173+ if "Reference at 'refs/heads/main' does not exist" in str (e ):
174+ logger .info ("No commit exists in the repository yet" )
175+ return None
176+ raise
171177
172178 @property
173179 def git_diff (self ) -> str :
Original file line number Diff line number Diff line change @@ -898,6 +898,10 @@ def checkout(
898898 result = self ._op .checkout_commit (commit_hash = commit )
899899 if result == CheckoutResult .SUCCESS :
900900 logger .info (f"Checked out { branch or commit } " )
901+ if self ._op .head_commit is None :
902+ logger .info ("No commit exists in the repository yet" )
903+ return CheckoutResult .SUCCESS
904+
901905 self .sync_to_commit (self ._op .head_commit )
902906 elif result == CheckoutResult .NOT_FOUND :
903907 logger .info (f"Could not find branch { branch or commit } " )
@@ -1435,6 +1439,7 @@ def from_string(
14351439
14361440 with tempfile .TemporaryDirectory (prefix = "codegen_" ) as tmp_dir :
14371441 logger .info (f"Using directory: { tmp_dir } " )
1442+
14381443 codebase = CodebaseFactory .get_codebase_from_files (repo_path = tmp_dir , files = files , programming_language = prog_lang )
14391444 logger .info ("Codebase initialization complete" )
14401445 return codebase
You can’t perform that action at this time.
0 commit comments