Skip to content

Commit

Permalink
refactor: a different way to apply a since=1-week default.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Sep 21, 2023
1 parent f8cf77c commit abdf8bb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ See the fragment files in the `scriv.d directory`_.
.. _changelog-1.3.2:

1.3.2 — 2023-09-19
1.3.2 — 2023-09-21
------------------

Fixed
.....

- fix: override default since param only if explicitly provided by cli #36
952bdfb introduced a regression ignoring the `since` parameter defined via
YAML config in favor of the default defined by the cli option
- The 1.3.1 fix for the ignore ``--since`` option accidentally ignored
``since`` settings in configuration files. This is now fixed, closing `issue
36`_. Thanks, `Lucas Taylor <pull 37_>`_.

.. _issue 36: https://github.com/nedbat/dinghy/issues/36
.. _pull 37: https://github.com/nedbat/dinghy/issues/37


.. _changelog-1.3.1:

Expand All @@ -49,6 +51,7 @@ Fixed

.. _issue 35: https://github.com/nedbat/dinghy/issues/35


.. _changelog-1.3.0:

1.3.0 — 2023-07-31
Expand Down
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ starting point for your own publishing.
.. _sample_repo: https://github.com/nedbat/dinghy_sample


Contributors
============

Thanks to all who have helped:

- Ned Batchelder
- Bill Mill
- Doug Hellmann
- Henry Gessau
- Lucas Taylor
- Quentin Pradet
- Simon de Vlieger


.. |pypi-badge| image:: https://img.shields.io/pypi/v/dinghy.svg
:target: https://pypi.python.org/pypi/dinghy/
Expand Down
9 changes: 2 additions & 7 deletions src/dinghy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ def main_run(coro):
@click.option(
"--since",
metavar="DELTA-OR-DATE",
help="Specify a since date.",
default="1 week",
show_default=True,
help="Specify a since date. [default: 1 week]",
)
@click.argument("_input", metavar="[INPUT]", default="dinghy.yaml")
@click.argument("digests", metavar="[DIGEST ...]", nargs=-1)
@click.pass_context
def cli(ctx, since, _input, digests):
def cli(since, _input, digests):
"""
Generate HTML digests of GitHub activity.
Expand All @@ -66,8 +63,6 @@ def cli(ctx, since, _input, digests):
if "://" in _input:
coro = make_digest([_input], since=since)
else:
source = ctx.get_parameter_source("since")
since = None if source.name == "DEFAULT" else since
coro = make_digests_from_config(_input, digests or None, since=since)

main_run(coro)
6 changes: 4 additions & 2 deletions src/dinghy/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,18 @@ def coro_from_item(digester, item):
return coro


async def make_digest(items, since="1 week", digest="digest.html", **options):
async def make_digest(items, since=None, digest="digest.html", **options):
"""
Make a single digest.
Args:
since (str): a duration spec ("2 day", "3d6h", etc).
since (optional str): a duration spec ("2 day", "3d6h", etc). Default: 1 week.
items (list[str|dict]): a list of YAML objects or GitHub URLs to collect entries from.
digest (str): the HTML file name to write.
"""
if since is None:
since = "1 week"
show_date = since != "forever"
since_date = parse_since(since)
digester = Digester(since=since_date, options=options)
Expand Down

0 comments on commit abdf8bb

Please sign in to comment.