Coder Social home page Coder Social logo

python-kacl's People

Contributors

ctrlc-root avatar dobernhardt avatar kianmeng avatar kiechlus avatar mschmieder avatar qu4tro avatar sykmschmieder avatar weakcamel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python-kacl's Issues

kacl-cli link generate fails

I've created an initial changelog as follows:

`# Changelog
All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

Added

  • Initial version
    `

kacl-cli link generate -m results in:

`CHANGELOG.md:6:3: error: Version "Unreleased" is linked, but no link reference found in changelog file.

[Unreleased]

^~~~~~~~~~~
1 error(s) generated.
PS C:\gitlab.com\webservices\surgical-case-service> kacl-cli link generate -m
Unexpected error occured. Make sure your file is a valid Mardown file.
Traceback (most recent call last):
File "c:\python38\lib\site-packages\kacl\kacl_cli.py", line 310, in start
cli(obj={})
File "c:\python38\lib\site-packages\click\core.py", line 764, in call
return self.main(*args, **kwargs)
File "c:\python38\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\python38\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\python38\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\python38\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\python38\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\python38\lib\site-packages\click\decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\python38\lib\site-packages\kacl\kacl_cli.py", line 120, in generate
kacl_changelog.generate_links(host_url=host_url,
File "c:\python38\lib\site-packages\kacl\document.py", line 373, in generate_links
versions[-1].set_link( link_provider.initial_version(**fargs) )
UnboundLocalError: local variable 'fargs' referenced before assignment`

bug: kacl-cli removes blank line at the end of CHANGELOG.md

When adding a new item to CHANGELOG.md via kacl-cli add or doing a new release via kacl_cli release, the blank line at the end of the file will be removed.

Without a blank line at the end of CHANGELOG.md, my pre-commit hook "fix end of files" fails (id: end-of-file-fixer).

The automatic modification of CHANGELOG.md by kacl-cli shouldn't remove any blank line at the end of the file.

[Feature Request] Pre-commit hook

It would be nice to have a pre-commit hook, that could be used to run kacl-cli verify.

Would you be open to a pull request that adds one to this repository? For reference, it should be adding a small file, like so:
https://github.com/psf/black/blob/main/.pre-commit-hooks.yaml

Thanks.

Support config in pyproject.toml

The pyproject.toml is supported by most linters/formatters/type checkers and other python utilities to be used as the configuration file. Would you consider adding support for it here too, instead of, or as an alternative to the current standalone config file?

Note that python <3.11 doesn't have any stdlib TOML parsing library, a commonly used one is tomli, which you can use as an optional dependency (extras), making support for pyproject.toml entirely optional and if people don't need it, but still providing it if it's installed, as it's pretty much the standard configuration place for python tools.

To do this, people can install the dependency like: pip install python-kacl[tomli] (you'll need to specify tomli as one of extras to the library in setup.py). Then, in the file where you're handling configuration file parsing, you can do something like:

from pathlib import Path
try:
    import tomli
except ImportError:
    tomli = None


def get_project_config():
    primary_cfg_file = Path(".kacl.yml")
    if primary_cfg_file.exists():
        return parse_yml_config(primary_cfg_file)
    
    secondary_cfg_file = Path("pyproject.toml")
    if secondary_cfg_file.exists():
        if tomli is not None:
            return parse_toml_config(secondary_cfg_file)
        raise NoConfigFound(".kacl.yml configuration file is missing, and tomli isn't installed so pyproject.toml is ignored")
        
    raise NoConfigFound(".kacl.yml nor pyproject.toml was found, project config missing")

Support poetry prerelease

Would be great to support prerelease versions for kacl. Maybe there's a workaround somewhere?

$ poetry version prerelease
Bumping version from 0.0.1 to 0.0.2a0

$ poetry run kacl-cli release 0.0.2a0
Error: "0.0.2a0" not a valid semantic version.

[Bug] Newlines are taken into consideration when they shouldn't

Hello there,

kacl-cli verify fails with

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

but succeeds with

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

I would expect for kacl-cli verify to succeed with both examples.

I think this is worth fixing for a few reasons:

  • Short lines > Long lines, in my opinion ๐Ÿ˜„ .
  • The official version in keepachangelog.com does come with the extra newline.
  • The markdown is rendered equally in the two given examples.

Thank you for creating this package!

Parse bug caused by invalid semantic version

If you look at lines 106 and 107 in document.py it appears start_pos and end_pos are being used before they are assigned leading to the following error:

Unexpected error occured. Make sure your file is a valid Mardown file.
Traceback (most recent call last):                                                    
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/kacl/kacl_cli.py", line 313, in start
    cli(obj={})                        
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)                                                 
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                                                  
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 610, in invoke                                                 
    return callback(*args, **kwargs)                                                  
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/kacl/kacl_cli.py", line 145, in verify
    valid = kacl_changelog.is_valid()                                                 
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/kacl/document.py", line 222, in is_valid
    validation_results = self.validate()                                              
  File "/home/alex/.virtualenvs/mk-eva/lib/python3.8/site-packages/kacl/document.py", line 106, in validate
    start_pos
UnboundLocalError: local variable 'start_pos' referenced before assignment

This was caused by a CHANGELOG.md file in a private repository which I can't share but given the location of the bug I don't think it should be too hard to reproduce it. If you can't reproduce it let me know and I will try to extract a minimal subset of the CHANGELOG.md that causes the issue.

Default setup not working

Using the latest python-kacl install, Python 3.7.3

There doesn't seem to be an example of how to start properly. Having never used versioning system with git, I followed these steps on a fresh branch with a virtualenv and a simple pip install python-kacl:

kacl-cli new CHANGELOG.md -> File created with default values
kacl-cli verify ->  "Success"
kacl-cli current -> returns null
kacl-cli add fixed 'We fixed some bad issues' --modify -> Adds new section to CHANGELOG.md called "fixed" with info
kacl-cli release 1.0.0 --auto-link

The last command returns a long error of which I will only return the end:

  File "/home/pi/.virtualenvs/test/lib/python3.7/site-packages/kacl/kacl_cli.py", line 253, in release
    kacl_changelog.release(version=version, link=link, auto_link=auto_link, increment=increment)
  File "/home/pi/.virtualenvs/test/lib/python3.7/site-packages/kacl/document.py", line 316, in release
    "previous_version": self.__versions[i+1].version(),
IndexError: list index out of range

Not sure what exactly to do from here. Doesn't seem I can create an initial version, or else I'm not using it properly. I added the Github config described at the bottom of the README as well.

Am I way off base here?

Addition checks

Here is a file that is considered valid by the tool:

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Entry outside subsection

### Security

- Unordered subsection

### Changed

- Duplicate subsection

### Changed

- Duplicate subsection

[Unreleased]: ...

Some additional checks (making this file invalid) could be :

  • Every entry belongs to a subsection
  • Subsections are always in the same order
  • There are no duplicate subsections

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.