Skip to content

Commit 45c1390

Browse files
committed
style: applies ruff formatting
1 parent af8a3cf commit 45c1390

2 files changed

Lines changed: 28 additions & 15 deletions

File tree

src/jinja2_git_dir/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,15 @@ def _git_default_branch(git_path: str) -> str:
4545

4646
# Try symbolic-ref for upstream, then origin (local, fast)
4747
for remote in ("upstream", "origin"):
48-
result = _run_git_command_at_path(
49-
git_path, ["symbolic-ref", f"refs/remotes/{remote}/HEAD"]
50-
)
48+
result = _run_git_command_at_path(git_path, ["symbolic-ref", f"refs/remotes/{remote}/HEAD"])
5149
if result:
5250
branch = _parse_symbolic_ref(result)
5351
if branch:
5452
return branch
5553

5654
# Try ls-remote for upstream, then origin (network, read-only)
5755
for remote in ("upstream", "origin"):
58-
result = _run_git_command_at_path(
59-
git_path, ["ls-remote", "--symref", remote, "HEAD"]
60-
)
56+
result = _run_git_command_at_path(git_path, ["ls-remote", "--symref", remote, "HEAD"])
6157
if result:
6258
branch = _parse_ls_remote_symref(result)
6359
if branch:

tests/test_jinja2_git_dir.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ def test_git_dir(git_path, mocked_toplevel_git_dir, expected, environment, fp):
5353
"/git-dir",
5454
{
5555
("git", "-C", "/git-dir", "rev-parse", "--is-inside-work-tree"): "true",
56-
("git", "-C", "/git-dir", "symbolic-ref", "refs/remotes/upstream/HEAD"):
57-
"refs/remotes/upstream/develop",
56+
(
57+
"git",
58+
"-C",
59+
"/git-dir",
60+
"symbolic-ref",
61+
"refs/remotes/upstream/HEAD",
62+
): "refs/remotes/upstream/develop",
5863
},
5964
"develop",
6065
),
@@ -72,8 +77,15 @@ def test_git_dir(git_path, mocked_toplevel_git_dir, expected, environment, fp):
7277
"/git-dir",
7378
{
7479
("git", "-C", "/git-dir", "rev-parse", "--is-inside-work-tree"): "true",
75-
("git", "-C", "/git-dir", "ls-remote", "--symref", "upstream", "HEAD"):
76-
"ref: refs/heads/master\tHEAD\nabc123\tHEAD\n",
80+
(
81+
"git",
82+
"-C",
83+
"/git-dir",
84+
"ls-remote",
85+
"--symref",
86+
"upstream",
87+
"HEAD",
88+
): "ref: refs/heads/master\tHEAD\nabc123\tHEAD\n",
7789
},
7890
"master",
7991
),
@@ -82,8 +94,15 @@ def test_git_dir(git_path, mocked_toplevel_git_dir, expected, environment, fp):
8294
"/git-dir",
8395
{
8496
("git", "-C", "/git-dir", "rev-parse", "--is-inside-work-tree"): "true",
85-
("git", "-C", "/git-dir", "ls-remote", "--symref", "origin", "HEAD"):
86-
"ref: refs/heads/trunk\tHEAD\nabc123\tHEAD\n",
97+
(
98+
"git",
99+
"-C",
100+
"/git-dir",
101+
"ls-remote",
102+
"--symref",
103+
"origin",
104+
"HEAD",
105+
): "ref: refs/heads/trunk\tHEAD\nabc123\tHEAD\n",
87106
},
88107
"trunk",
89108
),
@@ -130,9 +149,7 @@ def test_git_default_branch_conditional(environment, fp):
130149
)
131150
fp.allow_unregistered(allow=True)
132151

133-
template = environment.from_string(
134-
"{% if (git_path | gitdefaultbranch) %}yes{% else %}no{% endif %}"
135-
)
152+
template = environment.from_string("{% if (git_path | gitdefaultbranch) %}yes{% else %}no{% endif %}")
136153
assert template.render(git_path="/git-dir") == "yes"
137154
assert template.render(git_path="/non-git-dir") == "no"
138155

0 commit comments

Comments
 (0)