Skip to content

Commit

Permalink
Defer github.Repo.detect() execution to on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
bswck committed Feb 4, 2024
1 parent 48cb955 commit d87e873
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions jaraco/develop/add-github-secret.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

import autocommand

from . import github


@autocommand.autocommand(__name__)
def run(name, value, project: github.Repo = github.Repo.detect()):
project.add_secret(name, value)
def run(name, value, project: github.Repo | None = None):
(project or github.Repo.detect()).add_secret(name, value)
6 changes: 4 additions & 2 deletions jaraco/develop/add-github-secrets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import autocommand
import keyring
import getpass
Expand Down Expand Up @@ -32,8 +34,8 @@ def _safe_getuser():


@autocommand.autocommand(__name__)
def run(project: github.Repo = github.Repo.detect()):
for name in project.find_needed_secrets():
def run(project: github.Repo | None = None):
for name in (project or github.Repo.detect()).find_needed_secrets():
source = secret_sources[name]
value = keyring.get_password(**source)
project.add_secret(name, value)
6 changes: 4 additions & 2 deletions jaraco/develop/create-github-release.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import annotations

import autocommand

from . import github
from . import repo


@autocommand.autocommand(__name__)
def run(project: github.Repo = github.Repo.detect()):
def run(project: github.Repo | None = None):
md = repo.get_project_metadata()
project.create_release(tag=f'v{md.version}')
(project or github.Repo.detect()).create_release(tag=f'v{md.version}')

0 comments on commit d87e873

Please sign in to comment.