Skip to content

Commit

Permalink
Convert to pyproject.toml
Browse files Browse the repository at this point in the history
Update type hint, logging, and runtime
  • Loading branch information
dormant-user committed Jul 30, 2023
1 parent a824fb1 commit 10efb9a
Show file tree
Hide file tree
Showing 27 changed files with 878 additions and 11,980 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will upload a Python Package using Twine when a release is created
# This workflow will upload a Python Package using Twine when a release is created

name: pypi-publish

Expand All @@ -22,11 +22,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
pip install build twine
- name: Create packages
run: python -m build
- name: Run twine check
run: twine check dist/*
- name: Upload to pypi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*.whl
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*.whl
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
-
repo: https://gitlab.com/pycqa/flake8
repo: https://github.com/pycqa/flake8
rev: '3.9.2'
hooks:
-
Expand Down
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@
[![Pypi-format](https://img.shields.io/pypi/format/changelog-generator)](https://pypi.org/project/changelog-generator/#files)
[![Pypi-status](https://img.shields.io/pypi/status/changelog-generator)](https://pypi.org/project/changelog-generator)

![Maintained](https://img.shields.io/maintenance/yes/2022)
![Maintained](https://img.shields.io/maintenance/yes/2023)
[![GitHub Repo created](https://img.shields.io/date/1630367571)](https://api.github.com/repos/thevickypedia/changelog-generator)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/thevickypedia/changelog-generator)](https://api.github.com/repos/thevickypedia/changelog-generator)
[![GitHub last commit](https://img.shields.io/github/last-commit/thevickypedia/changelog-generator)](https://api.github.com/repos/thevickypedia/changelog-generator)

# CHANGELOG generator
Generate CHANGELOG from git commit history

### Pypi Module
[https://pypi.org/project/changelog-generator/][pypi]

### Usage
###### Navigate to the repository and run:
### Installation
```shell
pip install changelog-generator
```

### Usage
###### Regular CHANGELOG
```shell
changelog
Expand All @@ -47,15 +44,28 @@ changelog reverse
#### Sample
[release_notes.rst][release_notes]

### Pre-Commit
Install `pre-commit` to run `flake8` and `isort` for linting and `sphinx` for documentation generator.
### Linting
`PreCommit` will ensure linting, and the doc creation are run on every commit.

**Requirement**
```shell
pip install sphinx==5.1.1 pre-commit==2.20.0 recommonmark==0.7.1
```

**Usage**
```shell
pre-commit run --all-files
```

`pip install --no-cache --upgrade sphinx pre-commit recommonmark`
## Pypi Package
[![pypi-module](https://img.shields.io/badge/Software%20Repository-pypi-1f425f.svg)](https://packaging.python.org/tutorials/packaging-projects/)

`pre-commit run --all-files`
[https://pypi.org/project/changelog-generator/][pypi]

### Runbook
[GitHub Docs][runbook]
[![made-with-sphinx-doc](https://img.shields.io/badge/Code%20Docs-Sphinx-1f425f.svg)](https://www.sphinx-doc.org/en/master/man/sphinx-autogen.html)

[https://thevickypedia.github.io/changelog-generator/][runbook]

## License & copyright

Expand Down
3 changes: 0 additions & 3 deletions __init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions changemaker/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from changemaker.generator import main # noqa: F401

version = "0.7b"
18 changes: 10 additions & 8 deletions changemaker/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import subprocess
import time
from datetime import datetime
from typing import List, NoReturn, Union
from typing import List, NoReturn

import click

from changemaker import debugger

options = {'debug': False, 'reverse': False}
options = {'debug': False, 'reverse': False, 'start': 0.0}


def get_branches() -> List:
def get_branches() -> List[str]:
"""Runs ``git branch`` command to get the branches available for the repo.
Returns:
Expand All @@ -31,7 +31,7 @@ def get_branches() -> List:
debugger.error(error)


def get_gitlog(branch: str) -> List:
def get_gitlog(branch: str) -> List[str]:
"""Runs the command ``git log`` to get the all commit messages excluding merges and in reverse order.
Args:
Expand Down Expand Up @@ -72,7 +72,7 @@ def get_commits(trunk: str) -> int:
debugger.error(error) if options['debug'] else None


def generator(versions: List[str], gitlog: List[str]) -> Union[List[str], None]:
def generator(versions: List[str], gitlog: List[str]) -> List[str]:
"""Triggers the conversion process.
Returns:
Expand Down Expand Up @@ -133,14 +133,14 @@ def run(branch: str, filename: str, title: str) -> NoReturn:
debugger.error('No commit message found.') if options['debug'] else None
return

debugger.info(f'Generating {filename!r}') if options['debug'] else None
debugger.info('Generating snippets') if options['debug'] else None
snippets = generator(gitlog=gitlog,
versions=['.'.join(v for v in "{:03d}".format(n)) for n in range(1, commits + 1)])
if not snippets:
return

if options['reverse']:
debugger.warning(f'Generating {filename!r} from commit history in reverse order.') if options['debug'] else None
debugger.warning('Converting snippets to reverse order') if options['debug'] else None
snippets.reverse()

if os.path.isfile(filename):
Expand All @@ -150,7 +150,8 @@ def run(branch: str, filename: str, title: str) -> NoReturn:
file.write('%s\n%s\n\n' % (title, '=' * len(title)))
for index, each_snippet in enumerate(snippets):
file.write(f'{each_snippet}\n' if index + 1 < len(snippets) else each_snippet)
debugger.info(f'{filename!r} was created in: {round(float(time.perf_counter()), 2)}s') if options['debug'] else None
if options['debug']:
debugger.info(f"{filename!r} was created in: {round(float(time.time() - options['start']), 2)}s")


@click.command()
Expand Down Expand Up @@ -192,6 +193,7 @@ def main(*args, reverse: str = None, debug: str = None,
filename = 'CHANGELOG'
if title is None:
title = 'Change Log'
options['start'] = time.time()
run(branch=branch, filename=filename, title=title)


Expand Down
89 changes: 52 additions & 37 deletions docs/README.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<!DOCTYPE html>

<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
Expand All @@ -13,6 +13,7 @@
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>

<link rel="index" title="Index" href="genindex.html" />
Expand Down Expand Up @@ -47,68 +48,76 @@ <h3>Navigation</h3>
<a class="reference external" href="https://github.com/thevickypedia/changelog-generator/actions/workflows/python-publish.yml"><img alt="pypi" src="https://github.com/thevickypedia/changelog-generator/actions/workflows/python-publish.yml/badge.svg" /></a></p>
<p><a class="reference external" href="https://pypi.org/project/changelog-generator/#files"><img alt="Pypi-format" src="https://img.shields.io/pypi/format/changelog-generator" /></a>
<a class="reference external" href="https://pypi.org/project/changelog-generator"><img alt="Pypi-status" src="https://img.shields.io/pypi/status/changelog-generator" /></a></p>
<p><img alt="Maintained" src="https://img.shields.io/maintenance/yes/2022" />
<p><img alt="Maintained" src="https://img.shields.io/maintenance/yes/2023" />
<a class="reference external" href="https://api.github.com/repos/thevickypedia/changelog-generator"><img alt="GitHub Repo created" src="https://img.shields.io/date/1630367571" /></a>
<a class="reference external" href="https://api.github.com/repos/thevickypedia/changelog-generator"><img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/y/thevickypedia/changelog-generator" /></a>
<a class="reference external" href="https://api.github.com/repos/thevickypedia/changelog-generator"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/thevickypedia/changelog-generator" /></a></p>
<section id="changelog-generator">
<h1>CHANGELOG generator<a class="headerlink" href="#changelog-generator" title="Permalink to this headline"></a></h1>
<h1>CHANGELOG generator<a class="headerlink" href="#changelog-generator" title="Permalink to this heading"></a></h1>
<p>Generate CHANGELOG from git commit history</p>
<section id="pypi-module">
<h2>Pypi Module<a class="headerlink" href="#pypi-module" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://pypi.org/project/changelog-generator/">https://pypi.org/project/changelog-generator/</a></p>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<section id="navigate-to-the-repository-and-run">
<h3>Navigate to the repository and run:<a class="headerlink" href="#navigate-to-the-repository-and-run" title="Permalink to this headline"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip install changelog-generator
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h2>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span>changelog-generator
</pre></div>
</div>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this heading"></a></h2>
<section id="regular-changelog">
<h3>Regular CHANGELOG<a class="headerlink" href="#regular-changelog" title="Permalink to this headline"></a></h3>
<h3>Regular CHANGELOG<a class="headerlink" href="#regular-changelog" title="Permalink to this heading"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>changelog
</pre></div>
</div>
</section>
<section id="regular-changelog-in-debug-mode">
<h3>Regular CHANGELOG in debug mode<a class="headerlink" href="#regular-changelog-in-debug-mode" title="Permalink to this headline"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>changelog debug
<h3>Regular CHANGELOG in debug mode<a class="headerlink" href="#regular-changelog-in-debug-mode" title="Permalink to this heading"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>changelog<span class="w"> </span>debug
</pre></div>
</div>
</section>
<section id="changelog-in-reverse-order">
<h3>CHANGELOG in reverse order<a class="headerlink" href="#changelog-in-reverse-order" title="Permalink to this headline"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>changelog reverse
<h3>CHANGELOG in reverse order<a class="headerlink" href="#changelog-in-reverse-order" title="Permalink to this heading"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>changelog<span class="w"> </span>reverse
</pre></div>
</div>
</section>
<section id="flags">
<h3>Flags<a class="headerlink" href="#flags" title="Permalink to this headline"></a></h3>
<h3>Flags<a class="headerlink" href="#flags" title="Permalink to this heading"></a></h3>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">-b</span></code> Gather commit notes specific to a branch. Uses <code class="docutils literal notranslate"><span class="pre">Default</span> <span class="pre">branch</span></code> if not passed</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">-f</span></code> Write the commit notes to a custom filename. Defaults to <code class="docutils literal notranslate"><span class="pre">CHANGELOG</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">-t</span></code> Title or index line for the file generated. Defaults to <code class="docutils literal notranslate"><span class="pre">Change</span> <span class="pre">Log</span></code></p></li>
</ul>
</section>
<section id="sample">
<h3>Sample<a class="headerlink" href="#sample" title="Permalink to this headline"></a></h3>
<h3>Sample<a class="headerlink" href="#sample" title="Permalink to this heading"></a></h3>
<p><a class="reference external" href="https://github.com/thevickypedia/changelog-generator/blob/main/release_notes.rst">release_notes.rst</a></p>
</section>
</section>
<section id="pre-commit">
<h2>Pre-Commit<a class="headerlink" href="#pre-commit" title="Permalink to this headline"></a></h2>
<p>Install <code class="docutils literal notranslate"><span class="pre">pre-commit</span></code> to run <code class="docutils literal notranslate"><span class="pre">flake8</span></code> and <code class="docutils literal notranslate"><span class="pre">isort</span></code> for linting and <code class="docutils literal notranslate"><span class="pre">sphinx</span></code> for documentation generator.</p>
<p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">--no-cache</span> <span class="pre">--upgrade</span> <span class="pre">sphinx</span> <span class="pre">pre-commit</span> <span class="pre">recommonmark</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">pre-commit</span> <span class="pre">run</span> <span class="pre">--all-files</span></code></p>
<section id="linting">
<h2>Linting<a class="headerlink" href="#linting" title="Permalink to this heading"></a></h2>
<p><code class="docutils literal notranslate"><span class="pre">PreCommit</span></code> will ensure linting, and the doc creation are run on every commit.</p>
<p><strong>Requirement</strong></p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span><span class="nv">sphinx</span><span class="o">==</span><span class="m">5</span>.1.1<span class="w"> </span>pre-commit<span class="o">==</span><span class="m">2</span>.20.0<span class="w"> </span><span class="nv">recommonmark</span><span class="o">==</span><span class="m">0</span>.7.1
</pre></div>
</div>
<p><strong>Usage</strong></p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pre-commit<span class="w"> </span>run<span class="w"> </span>--all-files
</pre></div>
</div>
</section>
<section id="pypi-package">
<h2>Pypi Package<a class="headerlink" href="#pypi-package" title="Permalink to this heading"></a></h2>
<p><a class="reference external" href="https://packaging.python.org/tutorials/packaging-projects/"><img alt="pypi-module" src="https://img.shields.io/badge/Software%20Repository-pypi-1f425f.svg" /></a></p>
<p><a class="reference external" href="https://pypi.org/project/changelog-generator/">https://pypi.org/project/changelog-generator/</a></p>
<section id="runbook">
<h2>Runbook<a class="headerlink" href="#runbook" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://thevickypedia.github.io/changelog-generator/">GitHub Docs</a></p>
<h3>Runbook<a class="headerlink" href="#runbook" title="Permalink to this heading"></a></h3>
<p><a class="reference external" href="https://www.sphinx-doc.org/en/master/man/sphinx-autogen.html"><img alt="made-with-sphinx-doc" src="https://img.shields.io/badge/Code%20Docs-Sphinx-1f425f.svg" /></a></p>
<p><a class="reference external" href="https://thevickypedia.github.io/changelog-generator/">https://thevickypedia.github.io/changelog-generator/</a></p>
</section>
</section>
<section id="license-copyright">
<h2>License &amp; copyright<a class="headerlink" href="#license-copyright" title="Permalink to this headline"></a></h2>
<h2>License &amp; copyright<a class="headerlink" href="#license-copyright" title="Permalink to this heading"></a></h2>
<p>© Vignesh Sivanandha Rao, Changelog Generator</p>
<p>Licensed under the <a class="reference external" href="https://github.com/thevickypedia/changelog-generator/blob/master/LICENSE">MIT License</a></p>
</section>
Expand All @@ -121,29 +130,35 @@ <h2>License &amp; copyright<a class="headerlink" href="#license-copyright" title
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<div>
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">CHANGELOG generator</a><ul>
<li><a class="reference internal" href="#pypi-module">Pypi Module</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage</a><ul>
<li><a class="reference internal" href="#navigate-to-the-repository-and-run">Navigate to the repository and run:</a></li>
<li><a class="reference internal" href="#regular-changelog">Regular CHANGELOG</a></li>
<li><a class="reference internal" href="#regular-changelog-in-debug-mode">Regular CHANGELOG in debug mode</a></li>
<li><a class="reference internal" href="#changelog-in-reverse-order">CHANGELOG in reverse order</a></li>
<li><a class="reference internal" href="#flags">Flags</a></li>
<li><a class="reference internal" href="#sample">Sample</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pre-commit">Pre-Commit</a></li>
<li><a class="reference internal" href="#linting">Linting</a></li>
<li><a class="reference internal" href="#pypi-package">Pypi Package</a><ul>
<li><a class="reference internal" href="#runbook">Runbook</a></li>
</ul>
</li>
<li><a class="reference internal" href="#license-copyright">License &amp; copyright</a></li>
</ul>
</li>
</ul>

<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">Welcome to Changelog Generator’s documentation!</a></p>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">Welcome to Changelog Generator’s documentation!</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
Expand All @@ -160,7 +175,7 @@ <h3 id="searchlabel">Quick search</h3>
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
Expand All @@ -183,7 +198,7 @@ <h3>Navigation</h3>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2021, Vignesh Sivanandha Rao.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.2.0.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
</div>
</body>
</html>
Loading

0 comments on commit 10efb9a

Please sign in to comment.