Skip to content

Commit

Permalink
Extract version numbers explicitly
Browse files Browse the repository at this point in the history
Match tags with releases based on numbers
Update docs
  • Loading branch information
dormant-user committed Aug 19, 2023
1 parent 26c8bb4 commit 4b99f05
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 5 deletions.
6 changes: 6 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Commit History
==============

0.4.3 (08/18/2023)
------------------
- Extract version numbers explicitly
- Match tags with releases based on numbers
- Update docs

0.4.2 (08/15/2023)
------------------
- Add a new command for generic help
Expand Down
4 changes: 4 additions & 0 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ <h2 id="E">E</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#gitverse.debugger.error">error() (in module gitverse.debugger)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#gitverse.releases.extract_numbers_from_string">extract_numbers_from_string() (in module gitverse.releases)</a>
</li>
</ul></td>
</tr></table>
Expand Down
14 changes: 14 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ <h1>Welcome to GitVerse’s documentation!<a class="headerlink" href="#welcome-t
</section>
<section id="module-gitverse.releases">
<span id="releasenotes"></span><h1>ReleaseNotes<a class="headerlink" href="#module-gitverse.releases" title="Permalink to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="gitverse.releases.extract_numbers_from_string">
<span class="sig-prename descclassname"><span class="pre">gitverse.releases.</span></span><span class="sig-name descname"><span class="pre">extract_numbers_from_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_string</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">Generator</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Generator</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gitverse.releases.extract_numbers_from_string" title="Permalink to this definition"></a></dt>
<dd><p>Extract numbers or floating points in a string.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>input_string</strong> – String from which the numbers are to be extracted.</p>
</dd>
<dt class="field-even">Yields<span class="colon">:</span></dt>
<dd class="field-even"><p>Yields the string that is either a number or a dot.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="gitverse.releases.generate_snippets">
<span class="sig-prename descclassname"><span class="pre">gitverse.releases.</span></span><span class="sig-name descname"><span class="pre">generate_snippets</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#gitverse.releases.generate_snippets" title="Permalink to this definition"></a></dt>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gitverse/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "2.2"
version = "2.3"
25 changes: 22 additions & 3 deletions gitverse/releases.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import subprocess
import time
from collections.abc import Generator
from datetime import datetime
from typing import Dict, List, NoReturn, Union

Expand Down Expand Up @@ -76,6 +77,20 @@ def get_dates() -> Dict[str, int]:
return {line.split()[0]: int(line.split()[1]) for line in dates_values}


def extract_numbers_from_string(input_string: str) -> Union[Generator[str], Generator[int]]:
"""Extract numbers or floating points in a string.
Args:
input_string: String from which the numbers are to be extracted.
Yields:
Yields the string that is either a number or a dot.
"""
for s in input_string:
if s.isdigit() or s == '.':
yield s


def get_releases() -> Union[List[Dict[str, Union[str, List[str], int, str]]], None]:
"""Get releases mapped with the timestamp.
Expand Down Expand Up @@ -111,8 +126,12 @@ def get_releases() -> Union[List[Dict[str, Union[str, List[str], int, str]]], No
# Update release notes for each version, if available via GitHub API
if release_api := get_api_releases():
debugger.info(f"Release notes gathered: {len(release_api)}")
refinery = {
''.join(list(extract_numbers_from_string(input_string=key))): value
for key, value in release_api.items()
}
for version_update in version_updates:
if api_description := release_api.get(version_update['version']):
if api_description := release_api.get(version_update['version'], refinery.get(version_update['version'])):
version_update['description'] = api_description
if options['reverse']:
debugger.warning('Converting snippets to reverse order')
Expand All @@ -132,8 +151,8 @@ def generate_snippets() -> List[str]:
if loaded := get_releases():
snippets = []
for each_tag in loaded:
if each_tag['version'].startswith('v') or each_tag['version'].startswith('V'):
each_tag['version'] = each_tag['version'].replace('v', '').replace('V', '')
# remove all character elements from the version
each_tag['version'] = ''.join(list(extract_numbers_from_string(input_string=each_tag['version'])))
line1 = f"{each_tag['version']} ({each_tag['date']})"
line2 = "-" * len(line1)
description = []
Expand Down
4 changes: 4 additions & 0 deletions release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release Notes
=============

2.3 (08/18/2023)
----------------
- Improved accuracy on release notes mapping from git

2.2 (08/15/2023)
----------------
- Add a new command for generic help
Expand Down

0 comments on commit 4b99f05

Please sign in to comment.