omnilib / attribution Goto Github PK
View Code? Open in Web Editor NEWGenerate changelogs from commit tags and shortlogs
Home Page: https://attribution.omnilib.dev
License: MIT License
Generate changelogs from commit tags and shortlogs
Home Page: https://attribution.omnilib.dev
License: MIT License
Running attribution tag
on the attribution project results in tag being generated without a matching version.py file.
(venv) sam@sam-tobefilledbyoem:/PyCharmProjects/my_project$ attribution init
Project name [my_project]:
Package namespace [my_project]:
Use __version__.py file [Y/n]: Y
WARNING:attribution.tag:Skipping tag fixed_coder
WARNING:attribution.tag:Skipping tag fixed_logging
WARNING:attribution.tag:Skipping tag improved_tests
WARNING:attribution.tag:Skipping tag june_25th
WARNING:attribution.tag:Skipping tag major_refactor
WARNING:attribution.tag:Skipping tag ready_for_deployment_tests
WARNING:attribution.tag:Skipping tag smaller_fixes
WARNING:attribution.tag:Skipping tag working_rate_limit
Traceback (most recent call last):
File "/PyCharmProjects/my_project/venv/bin/attribution", line 8, in <module>
sys.exit(main())
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/attribution/main.py", line 63, in init
VersionFile(project).write()
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/attribution/generate.py", line 26, in write
content = self.generate()
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/attribution/generate.py", line 22, in generate
output = template.render(project=self.project, tags=tags, len=len)
File "/usr/lib/python3/dist-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in <module>
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 430, in getattr
return getattr(obj, attribute)
File "/PyCharmProjects/my_project/venv/lib/python3.9/site-packages/attribution/project.py", line 40, in latest
return self.tags[0]
IndexError: list index out of range
The sphinx lexer is wrongly assuming changelog's literal_block
s to be python3
.
Many warnings like:
sphinx-mdinclude/CHANGELOG.md:308: WARNING: Could not lex literal_block as "python3". Highlighting skipped
Should be fixed by hinting text
.
1.5.2
Currently, when running attribution tag
, the tag message template will include a list of commits since the previous tag, but the actual message will be empty. Many projects will keep an ongoing record of release notes in their CHANGELOG.md file leading up to a release, often at the top under a section heading named "next", "upcoming", or whatever the next expected release name will be.
It would be nice for attribution to look at the changelog itself, before generating the tag message template, to look for these common heading names or patterns, and if they exist, copy the contents of that section into the message template. For projects that are diligent about updating the changelog ahead of time, this will make new releases much easier, or at least remove the need to copy/paste the relevant portion of the changelog into the commit message.
For now, this could be done with some basic regex or markdown parsing, but with the potential for configurable changelog templates in the future, using a configurable search mechanism would be useful for allowing users to better specify what attribution should be looking for. The easy way is good enough for now if the configurable method doesn't fit well in the existing workflow.
I was trying out the package for the first time because it looks really good for my needs but I ran into an error that I'm having a hard time understanding.
Here's the command I ran + full traceback.
(dbt-sugar-lJO0x__U-py3.9) ➜ dbt-sugar git:(release/0.0.0-b.0) ✗ attribution tag -m "0.0.0-b.0" 0.0.0-b.0
Bump failed, version message in /Users/bastienboutonnet/repos/dbt-sugar/.attribution-0.0.0b0.txt, repo state unknown ¯\_(ツ)_/¯
Traceback (most recent call last):
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/bin/attribution", line 8, in <module>
sys.exit(main())
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/attribution/main.py", line 138, in tag_release
changelog = Changelog(project).write()
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/attribution/generate.py", line 26, in write
content = self.generate()
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/attribution/generate.py", line 22, in generate
output = template.render(project=self.project, tags=tags, len=len)
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<template>", line 8, in top-level template code
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/jinja2/environment.py", line 471, in getattr
return getattr(obj, attribute)
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/attribution/tag.py", line 53, in message
out = sh(f"git cat-file tag {self.name}")
File "/Users/bastienboutonnet/Library/Caches/pypoetry/virtualenvs/dbt-sugar-lJO0x__U-py3.9/lib/python3.9/site-packages/attribution/helpers.py", line 19, in sh
p = subprocess.run(
File "/Users/bastienboutonnet/.pyenv/versions/sugar_conda/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('git', 'cat-file', 'tag', 'v0.0.0-alpha.10')' returned non-zero exit status 128.
My only hunch is that maybe it's not liking my tag formats with the alpha bit in it?
~/git/abilian-sbe-monorepo$ attribution init
Project name [abilian-sbe-monorepo]:
Package namespace [abilian_sbe_monorepo]: abilian
Use __version__.py file [Y/n]: n
Use GPG signed tags [Y/n]: n
Traceback (most recent call last):
File "/home/fermigier/.cache/pypoetry/virtualenvs/abilian-sbe-Ez3cmVwm-py3.10/bin/attribution", line 8, in <module>
sys.exit(main())
File "/home/fermigier/.cache/pypoetry/virtualenvs/abilian-sbe-Ez3cmVwm-py3.10/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/home/fermigier/.cache/pypoetry/virtualenvs/abilian-sbe-Ez3cmVwm-py3.10/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/fermigier/.cache/pypoetry/virtualenvs/abilian-sbe-Ez3cmVwm-py3.10/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/fermigier/.cache/pypoetry/virtualenvs/abilian-sbe-Ez3cmVwm-py3.10/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/fermigier/.cache/pypoetry/virtualenvs/abilian-sbe-Ez3cmVwm-py3.10/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/fermigier/.cache/pypoetry/virtualenvs/abilian-sbe-Ez3cmVwm-py3.10/lib/python3.10/site-packages/attribution/main.py", line 63, in init
tool.append("attribution", table)
AttributeError: 'OutOfOrderTableProxy' object has no attribute 'append'
Add pessimist to make test
or CI or something.
Currently, running attribution tag
will not only create tags and update changelog, but also write a __version__.py
in the project namespace. This is redundant for projects already using something like setuptools_scm
to manage version info, so an option to disable this is desired.
The option to disable this should be something like:
pyproject.toml
[tool.attribution]
version_file = false
Set a default value of True
for this in attribution.Project.load()
, then around attribution/main.py:73
, this value can be retrieved from Project.config
and used to determine if the version file should be written or skipped.
The git describe
command to find the previous tag always just generates the previous rev, rather than a tag name, for the first tag:
(.venv) jreese@mordin ~/workspace/ufmt diff » attribution --debug generate
DEBUG:attribution.main:project: Project(name='µfmt', package='ufmt', config={'version_file': True, 'signed_tags': True,
'name': 'µfmt', 'package': 'ufmt'}, _shortlog=None, _tags=[])
DEBUG:attribution.helpers:running $ git tag
DEBUG:attribution.helpers:running $ git cat-file tag v1.0
DEBUG:attribution.helpers:running $ git describe --tags --abbrev=0 --always 'v1.0~1'
DEBUG:attribution.helpers:running $ git shortlog -s 245e1a1d2047842e60a76ebebfcb108d90786c57...v1.0
µfmt
====
v1.0
----
Initial release
* `format` command formats files in place
* `check` command validates existing formatting
* Basic readme and sphinx docs
$ git shortlog -s 245e1a1d2047842e60a76ebebfcb108d90786c57...v1.0
1 John Reese
attribution uses this as the base for the shortlog for each tag, resulting in invalid shortlogs for the first tag consisting of a single contributor. For these early tags, attribution should instead be taking a shortlog from the beginning of the repo to that tag.
amethyst@palkia ~/workspace/Fixit main » git cat-file tag v0.1.4
fatal: git cat-file v0.1.4: bad file
Make it clear that a CHANGELOG.md
and __version__.py
are handled by attribution.
As discussed there:
- re version: this is also managed by attribution, so please do not change the version file directly. Perhaps attribution could add a simple comment explaining that.
Originally posted by @amyreese in https://github.com/amyreese/sphinx-mdinclude/issues/13#issuecomment-1241432354
Currently, attribution tag
just calls git tag -s
when it's ready to (re)create the final tagged version. Some maintainers don't want to use signed tags. We should support this via a config option in pyproject.toml.
Expected config would look something like:
pyproject.toml
[tool.attribution]
signed_tags=false
This should get stored in Project.config["signed_tags"]
, in attribution/project.py
, with a default value of True
if no value is set, and would be used in attribution/main.py:83
when updating the new tag. attribution/tag.py:123
should probably also be updated to use --no-sign
instead of --annotated
.
This can be tested by creating a simple git repo and running attribution tag 1.0
with or without the pyproject.toml config set, and then running git show v1.0
to see if it includes a GPG signature or not. Adding unit tests covering the cli command itself would be useful, but not necessary.
(venv37) jreese@garbodor ~/scratch » pip install attribution
Collecting attribution
Downloading attribution-1.2.0-py3-none-any.whl (12 kB)
Requirement already satisfied: packaging in ./venv37/lib/python3.7/site-packages (from attribution) (20.4)
Collecting click
Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting attrs
Using cached attrs-20.2.0-py2.py3-none-any.whl (48 kB)
Collecting jinja2
Using cached Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
Requirement already satisfied: pyparsing>=2.0.2 in ./venv37/lib/python3.7/site-packages (from packaging->attribution) (2.4.7)
Requirement already satisfied: six in ./venv37/lib/python3.7/site-packages (from packaging->attribution) (1.15.0)
Collecting MarkupSafe>=0.23
Using cached MarkupSafe-1.1.1-cp37-cp37m-macosx_10_6_intel.whl (18 kB)
Installing collected packages: click, attrs, MarkupSafe, jinja2, attribution
Successfully installed MarkupSafe-1.1.1 attribution-1.2.0 attrs-20.2.0 click-7.1.2 jinja2-2.11.2
(venv37) jreese@garbodor ~/scratch » rehash
(venv37) jreese@garbodor ~/scratch » attribution --help
Traceback (most recent call last):
File "/Users/jreese/scratch/venv37/bin/attribution", line 5, in <module>
from attribution.main import main
File "/Users/jreese/scratch/venv37/lib/python3.7/site-packages/attribution/main.py", line 12, in <module>
from .generate import Changelog
File "/Users/jreese/scratch/venv37/lib/python3.7/site-packages/attribution/generate.py", line 8, in <module>
from .project import Project
File "/Users/jreese/scratch/venv37/lib/python3.7/site-packages/attribution/project.py", line 9, in <module>
import toml
ModuleNotFoundError: No module named 'toml'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.