Skip to content

Commit

Permalink
fix: check for exactly one line in call_git_oneline
Browse files Browse the repository at this point in the history
This commit prevents a possible `IndexError` in
`call_git_oneline` if `git` returns less than
one line.
  • Loading branch information
christian-monch committed Oct 25, 2024
1 parent 9ab7305 commit 53accc0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions datalad_core/runners/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ def call_git_oneline(
Raises
------
CommandError if the call exits with a non-zero status.
AssertionError if there is more than one line of output.
AssertionError if there is not exactly one line of output.
"""
lines = call_git_lines(args, cwd=cwd, inputs=inputs, force_c_locale=force_c_locale)
if len(lines) > 1:
if len(lines) != 1:
msg = f'Expected Git {args} to return a single line, but got {lines}'
raise AssertionError(msg)
return lines[0]
Expand Down

0 comments on commit 53accc0

Please sign in to comment.