Skip to content

Commit

Permalink
Add python dotenv to load env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Aug 10, 2023
1 parent 2a70af7 commit e231c84
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Commit History
==============

0.3.9 (08/10/2023)
------------------
- Add python dotenv to load env vars

0.3.8 (08/10/2023)
------------------
- Get it to a better state
Expand Down
1 change: 1 addition & 0 deletions docs/_static/pygments.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
Expand Down
2 changes: 1 addition & 1 deletion gitverse/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "2.0a"
version = "2.0b"
12 changes: 10 additions & 2 deletions gitverse/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Dict, List, NoReturn, Union

import click
import dotenv
import requests

from gitverse import debugger
Expand Down Expand Up @@ -172,8 +173,9 @@ def run(filename: str, title: str) -> NoReturn:
@click.option("-v", "--version", required=False, is_flag=True, help="Get version of the package")
@click.option("-f", "--filename", help="Filename where the commit notes should be stored")
@click.option("-t", "--title", help="Title under which the commit notes should be stored")
@click.option("-e", "--env", help="Filename/filepath for .env file to load the environment variables")
def main(*args, reverse: str = None, debug: str = None,
version: str = None, filename: str = None, title: str = None) -> None:
version: str = None, filename: str = None, title: str = None, env: str = None) -> None:
"""Generate a reStructuredText/Markdown file using github releases.
Run 'gitverse-commit reverse' to generate release notes in reverse order.
Expand All @@ -183,6 +185,7 @@ def main(*args, reverse: str = None, debug: str = None,
if version:
debugger.info(pkg_version)
return
options['start'] = time.time()
reverse = reverse or ''
debug = debug or ''

Expand All @@ -208,7 +211,12 @@ def main(*args, reverse: str = None, debug: str = None,
filename = 'ReleaseNotes'
if title is None:
title = 'Release Notes'
options['start'] = time.time()
if env is None:
env = '.env'
kwargs = dict(dotenv_path=env, override=True, verbose=False)
if options['debug']:
kwargs['verbose'] = True
dotenv.load_dotenv(**kwargs)
run(filename=filename, title=title)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
]
keywords = ["changelog", "automate", "commits", "releases"]
requires-python = ">=3.8"
dependencies = ["click", "requests"]
dependencies = ["click", "requests", "python-dotenv"]

[tool.setuptools]
packages = ["gitverse"]
Expand Down
11 changes: 11 additions & 0 deletions release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Release Notes
=============

2.0b (08/10/2023)
-----------------
- Use ``python-dotenv`` to load env vars for ``git_token``
- Add CLI option to pass filename/filepath for dot env

2.0a (08/10/2023)
-----------------
- Use ``git pull`` before any operation
- Make an API call to github to get accurate release information (if available)
- Improve accuracy

0.7 (07/30/2023)
----------------
- Add ``version`` argument
Expand Down

0 comments on commit e231c84

Please sign in to comment.