15 Commits
1.0.4 ... 1.1.2

Author SHA1 Message Date
0666f7f593 Release Version 1.1.2
### Changed

- yaclog now only tries to use git when invoked with a command that needs it, meaning most sub commands can now be used on systems without git
2022-12-29 00:34:58 -08:00
51e28e4ef0 cleanup 2022-12-29 00:34:27 -08:00
a7cbacb687 Update changelog 2022-12-28 20:49:58 -08:00
3fa529a05c Bump actions/setup-python from 4.3.1 to 4.4.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.3.1 to 4.4.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.3.1...v4.4.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-27 20:26:05 -08:00
396960fae0 Only import toml and gitpython when necessary
Allows for using most commands on platforms without git installed (like the a-shell app on ios where gitpython doesnt quite work)
2022-12-27 20:21:18 -08:00
c661be05dc Bump actions/setup-python from 4.2.0 to 4.3.1
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.2.0 to 4.3.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.2.0...v4.3.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-12 23:34:48 -08:00
2f4124c0fc Test with python 3.11 2022-12-12 23:33:48 -08:00
465b818ca2 Release Version 1.1.1
### Fixed

- Fixed `yaclog release -C -c` not committing changes to cargo.toml
2022-08-14 17:39:12 -07:00
32f20e677e Release Version 1.1.0
### Added

- Added a flag to update Rust Cargo.toml files when releasing a new version
2022-08-13 20:03:24 -07:00
8421d38164 Add cargo.toml support
Added a flag to update Rust Cargo.toml files when releasing a new version
2022-08-13 20:02:45 -07:00
c5030b6060 Bump actions/setup-python from 4.0.0 to 4.2.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.0.0 to 4.2.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.0.0...v4.2.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-04 23:57:53 -07:00
4ce3de25c7 Bump actions/setup-python from 3.1.2 to 4.0.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3.1.2 to 4.0.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3.1.2...v4.0.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-09 23:15:47 -07:00
6bc99c585b Merge pull request #3 from drewcassidy/dependabot/github_actions/actions/setup-python-3.1.2
Bump actions/setup-python from 3.1.1 to 3.1.2
2022-04-12 18:24:29 -07:00
32abd7bc6b Bump actions/setup-python from 3.1.1 to 3.1.2
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3.1.1...v3.1.2)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-12 11:18:19 +00:00
06df766f9f Remove license metadata (troves are fine)
oops: https://cybre.space/@cinebox/108095181597001366
2022-04-08 00:13:06 -07:00
6 changed files with 104 additions and 13 deletions

View File

@ -9,14 +9,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
click-version: [ "click~=7.0", "click~=8.0" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3.1.1
uses: actions/setup-python@v4.4.0
with:
python-version: ${{ matrix.python-version }}
@ -48,7 +48,7 @@ jobs:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3.1.1
uses: actions/setup-python@v4.4.0
with:
python-version: '3.x'

View File

@ -2,6 +2,27 @@
All notable changes to this project will be documented in this file
## Version 1.1.2 - 2022-12-29
### Changed
- yaclog now only tries to use git when invoked with a command that needs it, meaning most sub commands can now be used on systems without git
## Version 1.1.1 - 2022-08-15
### Fixed
- Fixed `yaclog release -C -c` not committing changes to cargo.toml
## Version 1.1.0 - 2022-08-14
### Added
- Added a flag to update Rust Cargo.toml files when releasing a new version
## Version 1.0.4 - 2022-04-08
### Fixed

View File

@ -10,7 +10,6 @@ build-backend = "setuptools.build_meta"
name = "yaclog"
description = "Yet another changelog CLI tool."
readme = "README.md"
license = { file = "LICENSE.md" }
authors = [{ name = "Andrew Cassidy", email = "drewcassidy@me.com" }]
keywords = ["changelog", "commandline", "markdown"]
classifiers = [
@ -32,7 +31,9 @@ requires-python = ">= 3.8"
dependencies = [
"Click >= 7.0",
"GitPython >= 3",
"packaging >= 20"
"packaging >= 20",
"tomlkit >= 0.11"
]
dynamic = ["version"]

View File

@ -217,6 +217,31 @@ class TestRelease(unittest.TestCase):
self.assertIn(repo.head.commit.hexsha[0:7], result.output)
self.assertEqual(repo.tags[0].name, '1.0.0')
def test_cargo(self):
"""Test updating cargo.toml files"""
runner = CliRunner()
with runner.isolated_filesystem():
with open("Cargo.toml", "w") as fp:
fp.write((
'[package]\n'
'name = "dummy"\n'
'version = "0.3.4"\n'
'authors = ["Andrew Cassidy <drewcassidy@me.com>"]\n'
'description = "A dummy crate used for testing yaclog"\n'
'keywords = ["does", "not", "exist"]\n'
'edition = "2018"\n'
))
runner.invoke(cli, ['init']) # create the changelog
runner.invoke(cli, ['entry', '-b', 'entry number 1'])
result = runner.invoke(cli, ['release', 'Version 1.0.0', '-C'])
check_result(self, result)
with open("Cargo.toml", "r") as fp:
self.assertIn('version = "1.0.0"', fp.read())
# we're just going to trust tomlkit not to mangle everything else
class TestShow(unittest.TestCase):

View File

@ -18,7 +18,6 @@ import datetime
import os.path
import click
import git
import yaclog.version
from yaclog.changelog import Changelog
@ -51,7 +50,7 @@ def init(obj: Changelog):
click.echo(f'Created new changelog file at {obj.path}')
@cli.command('format') # dont accidentally hide the `format` python builtin
@cli.command('format') # don't accidentally hide the `format` python builtin
@click.pass_obj
def reformat(obj: Changelog):
"""Reformat the changelog file."""
@ -199,9 +198,11 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name):
@click.option('-c', '--commit', is_flag=True,
help='Create a git commit tagged with the new version number. '
'If there are no changes to commit, the current commit will be tagged instead.')
@click.option('-C', '--cargo', '-🦀', is_flag=True,
help='Update the version in a Rust cargo.toml manifest file.')
@click.argument('version_name', metavar='VERSION', type=str, default=None, required=False)
@click.pass_obj
def release(obj: Changelog, version_name, rel_seg, pre_seg, commit):
def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
"""
Release VERSION, or a version incremented from the last release.
@ -213,7 +214,7 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit):
other kinds of prerelease.
"""
if rel_seg is None and pre_seg is None and not version_name and not commit:
if rel_seg is None and pre_seg is None and not version_name and not commit and not cargo:
click.echo('Nothing to release!')
raise click.Abort
@ -246,7 +247,17 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit):
obj.write()
click.echo(f"Renamed {click.style(old_name, fg='blue')} to {click.style(new_name, fg='blue')}")
short_version, *_ = yaclog.version.extract_version(cur_version.name)
if not short_version:
short_version = cur_version.name.replace(' ', '-')
if cargo:
from ..cli import cargo_toml
cargo_toml.set_version("Cargo.toml", str(short_version))
click.echo("Updated Cargo.toml")
if commit:
import git
repo = git.Repo(os.curdir)
if repo.bare:
@ -254,6 +265,9 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit):
repo.index.add(obj.path)
if cargo:
repo.index.add("Cargo.toml")
tracked = len(repo.index.diff(repo.head.commit))
untracked = len(repo.index.diff(None))
@ -277,10 +291,7 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit):
else:
commit = repo.head.commit
short_version, *_ = yaclog.version.extract_version(cur_version.name)
if not short_version:
short_version = cur_version.name.replace(' ', '-')
# noinspection PyTypeChecker
repo_tag = repo.create_tag(short_version, ref=commit, message=cur_version.body(False))
click.echo(f"Created tag {click.style(repo_tag.name, fg='green')}.")

33
yaclog/cli/cargo_toml.py Normal file
View File

@ -0,0 +1,33 @@
# yaclog: yet another changelog tool
# Copyright (c) 2022. Andrew Cassidy
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from tomlkit import dumps
from tomlkit import parse
def set_version(path, version):
"""
Set the version string in a cargo.toml file
:param path: path-like file location
:param version: version string to overwrite with
"""
with open(path, 'r+') as fp:
toml = parse(fp.read())
toml['package']['version'] = version
fp.seek(0)
fp.write(dumps(toml))
fp.truncate()