Skip to content

Commit

Permalink
Fix commit parent handling (#284)
Browse files Browse the repository at this point in the history
* Fix typo

Without this fix, we don't catch the exception at the first commit (with
no parents) and we dump instead of completing the final step of the
scan.

* Fix handler more

And document why we're catching what we're catching

* Change log update

* Kickstart CI testing

Co-authored-by: Scott Bailey <scott.bailey@godaddy.com>
  • Loading branch information
rbailey-godaddy and rscottbailey authored Nov 15, 2021
1 parent 28813a9 commit 63eabca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
vx.y.z - TBD
------------

Bug fixes:

* [#284](https://github.com/godaddy/tartufo/pull/284) - Fix handling of first
commit during local scans; an exception was raised instead of processing the
commit.

Features:

* [#270](https://github.com/godaddy/tartufo/issues/270) - When no refs/branches
Expand Down
4 changes: 3 additions & 1 deletion tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,9 @@ def chunks(self) -> Generator[types.Chunk, None, None]:
for curr_commit in commits:
try:
prev_commit = curr_commit.parents[0]
except (KeyError, TypeError):
except (IndexError, KeyError, TypeError):
# IndexError: current commit has no parents
# KeyError: current commit has parents which are not local
# If a commit doesn't have a parent skip diff generation since it is the first commit
self.logger.debug(
"Skipping commit %s because it has no parents", curr_commit.hex
Expand Down

0 comments on commit 63eabca

Please sign in to comment.