Skip to content

Commit

Permalink
Fiksz
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Jun 30, 2023
1 parent ebaedb2 commit 69641c9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions porcupine/plugins/git_blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pathlib import Path
from typing import NamedTuple

from porcupine import get_tab_manager, utils
from porcupine import get_tab_manager, tabs, utils

log = logging.getLogger(__name__)

Expand All @@ -19,7 +19,7 @@

class Commit(NamedTuple):
revision: int
message: str
subject: str
author: str
date: datetime

Expand All @@ -45,7 +45,7 @@ def is_in_git_repo(path: Path) -> bool:

def git_blame_get_commit(path: Path, line: int) -> Commit | None:
if not path or not is_in_git_repo(path):
# TODO: Do we have to run this every time?
# TODO: Do we have to check this every time?
return None

try:
Expand All @@ -69,17 +69,17 @@ def git_blame_get_commit(path: Path, line: int) -> Commit | None:

git_log_result = run_git("log", "-n", "1", "--pretty=format:%s", revision, cwd=path.parent)

return Commit(revision, git_log_result.stdout, author, date)
return Commit(int(revision), git_log_result.stdout, author, date)


def show_git_blame_message(path: Path, event) -> None:
line_num = int(event.widget.index("insert").split(".")[0])

res = git_blame_get_commit(path=path, line=line_num)
if res is None:
commit = git_blame_get_commit(path=path, line=line_num)
if commit is None:
return

formatted = f"Line {line_num}: by {res.author} at {res.date} - {res.message}"
formatted = f"Line {line_num}: by {commit.author} at {commit.date} - {commit.subject}"
print(formatted)


Expand Down

0 comments on commit 69641c9

Please sign in to comment.