Skip to content

Commit

Permalink
Simplify blame_file()
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Oct 28, 2023
1 parent 7103ba3 commit a5243fc
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions gitblame.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,14 @@ def blame_file(self, file: str) -> dict | None:
time.sleep(wait_time)
continue
response.raise_for_status()
try:
data = response.json()["data"]
except KeyError:
logging.error("%s: %s: %s", file, response.text, response.headers)
return None
return data["repositoryOwner"]["repository"]["object"]["blame"][
"ranges"
]
data = response.json()["data"]
except RequestException as exc:
logging.error("%s: %s", file, exc)
return None
except KeyError:
logging.error("%s: %s: %s", file, response.text, response.headers)
return None
return data["repositoryOwner"]["repository"]["object"]["blame"]["ranges"]
return None

def blame_line(self, file: str, line: int) -> tuple[str, str, str, datetime]:
Expand Down

0 comments on commit a5243fc

Please sign in to comment.