Skip to content

Commit

Permalink
fixup ahead and behind per Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Spitfire1900 committed Mar 28, 2024
1 parent d5391e4 commit 626b5b2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions xontrib/pygitstatus/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def ahead(fld: PromptField, ctx: PromptFields):
repo = Repo('.')

local_commit = repo.head.target
if local_branch := repo.branches.get(repo.head.shorthand):
if (upstream := local_branch.upstream) is not None:
upstream_commit = upstream.target
ahead, behind = repo.ahead_behind(local_commit, upstream_commit)
local_branch = repo.branches.get(repo.head.shorthand)
if local_branch is not None and (upstream := local_branch.upstream) is not None:
upstream_commit = upstream.target
ahead, behind = repo.ahead_behind(local_commit, upstream_commit)

fld.value = str(ahead) if ahead else ''

Expand All @@ -37,10 +37,10 @@ def behind(fld: PromptField, ctx: PromptFields):
repo = Repo('.')

local_commit = repo.head.target
if local_branch := repo.branches.get(repo.head.shorthand):
if (upstream := local_branch.upstream) is not None:
upstream_commit = upstream.target
ahead, behind = repo.ahead_behind(local_commit, upstream_commit)
local_branch = repo.branches.get(repo.head.shorthand)
if local_branch is not None and (upstream := local_branch.upstream) is not None:
upstream_commit = upstream.target
ahead, behind = repo.ahead_behind(local_commit, upstream_commit)

fld.value = str(behind) if behind else ''

Expand Down

0 comments on commit 626b5b2

Please sign in to comment.