Skip to content

Commit a65e41e

Browse files
committed
context: add profile property
Passed in by dput when the hooks are called.
1 parent 709b348 commit a65e41e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ubuntu_lint/context.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Context:
3636
def __init__(
3737
self,
3838
changes: str | deb822.Changes | None = None,
39+
profile: dict | None = None,
3940
debian_changelog: str | changelog.Changelog | None = None,
4041
launchpad_handle: Launchpad | None = None,
4142
source_dir: str | None = None,
@@ -58,6 +59,10 @@ def __init__(
5859
elif changes is not None:
5960
raise ValueError("invalid type for changes")
6061

62+
self._profile: dict | None = None
63+
if profile is not None:
64+
self._profile = profile
65+
6166
self._changelog: changelog.Changelog | None = None
6267
if isinstance(debian_changelog, str):
6368
with open(debian_changelog, "r") as f:
@@ -83,6 +88,14 @@ def changes(self) -> deb822.Changes:
8388
assert self._changes is not None
8489

8590
return self._changes
91+
92+
@property
93+
def profile(self) -> dict:
94+
if not self._profile:
95+
raise MissingContextException("missing context for upload profile")
96+
assert self._profile is not None
97+
98+
return self._profile
8699

87100
def changelog_entry_by_index(self, index: int) -> changelog.ChangeBlock:
88101
if not self._changelog:

ubuntu_lint/dput.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def call_lint_as_hook(
1616
interface: CLInterface,
1717
can_ignore: bool = False,
1818
):
19-
context = ubuntu_lint.Context(changes=changes.get_raw_changes())
19+
context = ubuntu_lint.Context(changes=changes.get_raw_changes(), profile=profile)
2020
try:
2121
lint(context)
2222
except ubuntu_lint.LintFailure as e:

0 commit comments

Comments
 (0)