Browse Source

bump releases changelog

shut-new-model
Niklas Rosenstein 9 months ago
parent
commit
7bf018183b
No known key found for this signature in database GPG Key ID: 6D269B33D25F6C6
8 changed files with 39 additions and 17 deletions
  1. + 0
    - 2
      README.md
  2. + 22
    - 5
      src/shut/commands/commons/bump.py
  3. + 1
    - 1
      src/shut/commands/commons/checks.py
  4. + 10
    - 3
      src/shut/commands/commons/new.py
  5. + 1
    - 1
      src/shut/commands/mono/bump.py
  6. + 2
    - 2
      src/shut/commands/mono/update.py
  7. + 1
    - 1
      src/shut/commands/pkg/bump.py
  8. + 2
    - 2
      src/shut/commands/pkg/update.py

+ 0
- 2
README.md

@ -36,8 +36,6 @@ __Todo__
* [ ] build/publish commands
* [ ] Bump version based on changelog
* [ ] Bump for monorepository
* [ ] Bump release staged changelog
* [ ] Command to install and save requirements
* [ ] Package data / data files
* [ ] Conda recipe generator and conda-forge helper

+ 22
- 5
src/shut/commands/commons/bump.py

@ -26,11 +26,13 @@ import sys
from typing import Iterable, Generic, Optional, T, Type
import click
import nr.fs
from databind.core import datamodel
from nr.stream import Stream
from nr.utils.git import Git
from termcolor import colored
from shut.changelog.manager import ChangelogManager
from shut.commands import project
from shut.model import AbstractProjectModel, Project
from shut.model.version import bump_version, parse_version, Version
@ -92,9 +94,9 @@ class VersionBumpData(Generic[T], metaclass=abc.ABCMeta):
if len(refs) == 1:
ref = refs[0]
print(f' {colored(os.path.relpath(ref.filename), "cyan")}: {ref.value} → {target_version}')
print(f' {colored(nr.fs.rel(ref.filename), "cyan")}: {ref.value} → {target_version}')
else:
print(f' {colored(os.path.relpath(ref.filename), "cyan")}:')
print(f' {colored(nr.fs.rel(ref.filename), "cyan")}:')
for ref in refs:
print(f' {ref.value} → {target_version}')
@ -107,7 +109,22 @@ class VersionBumpData(Generic[T], metaclass=abc.ABCMeta):
with open(filename, 'w') as fp:
fp.write(content)
return list(set(x.filename for x in version_refs))
changed_files = set(x.filename for x in version_refs)
# Release the staged changelog.
manager = ChangelogManager(self.obj.get_changelog_directory())
if manager.unreleased.exists():
changed_files.add(manager.unreleased.filename)
if self.args.dry:
changelog = manager.version(target_version)
else:
changelog = manager.release(target_version)
changed_files.add(changelog.filename)
print()
print('release staged changelog')
print(f' {colored(nr.fs.rel(manager.unreleased.filename), "cyan")} → {nr.fs.rel(changelog.filename)}')
return changed_files
@abc.abstractmethod
def update(self) -> None:
@ -201,12 +218,12 @@ def do_bump(args: Args, data: VersionBumpData[AbstractProjectModel]) -> None:
logger.warning(f'new version "{new_version}" is equal to current version')
exit(0)
# Bump version numbers in files.
changed_files = list(data.bump_to_version(new_version))
# TODO(NiklasRosenstein): Release staged changelogs.
if not args.skip_update:
print()
print('updating files')
data.update()
if args.tag:

+ 1
- 1
src/shut/commands/commons/checks.py

@ -67,7 +67,7 @@ def print_checks_all(name: str, checks: List[Check], seconds: float):
print()
print_checks(checks, prefix=' ')
print()
print('run', len(checks), 'checks for package', package_name, 'in {:.3f}s'.format(seconds))
print('ran', len(checks), 'checks for package', package_name, 'in {:.3f}s'.format(seconds))
def get_checks_status(checks: List[Check], warnings_as_errors: bool = False) -> int:

+ 10
- 3
src/shut/commands/commons/new.py

@ -76,16 +76,23 @@ def render_template(fp, template_string, template_vars):
fp.write('\n')
def write_files(files: VirtualFiles, target_directory: str, force: bool = False, dry: bool = False):
def write_files(
files: VirtualFiles,
target_directory: str,
force: bool = False,
dry: bool = False,
indent: int = 0,
) -> None:
def _rel(fn: str) -> str:
path = os.path.relpath(fn)
if nr.fs.issub(path):
return path
return fn
str_indent = ' ' * indent
files.write_all(
target_directory,
on_write=lambda fn: print(colored('Write ' + _rel(fn), 'cyan')),
on_skip=lambda fn: print(colored('Skip ' + _rel(fn), 'yellow')),
on_write=lambda fn: print(str_indent + colored('write ' + _rel(fn), 'cyan')),
on_skip=lambda fn: print(str_indent + colored('skip ' + _rel(fn), 'yellow')),
overwrite=force,
dry=dry,
)

+ 1
- 1
src/shut/commands/mono/bump.py

@ -46,7 +46,7 @@ class MonorepoBumpdata(VersionBumpData[MonorepoModel]):
return check_monorepo(self.obj, self.args.warnings_as_errors)
def update(self) -> None:
update_monorepo(self.obj, dry=self.args.dry)
update_monorepo(self.obj, dry=self.args.dry, indent=1)
def bump_to_version(self, target_version: Version) -> Iterable[str]:
changed_files = list(super().bump_to_version(target_version))

+ 2
- 2
src/shut/commands/mono/update.py

@ -29,9 +29,9 @@ from shut.update import get_files
from . import mono
def update_monorepo(monorepo: MonorepoModel, dry: bool = False) -> None:
def update_monorepo(monorepo: MonorepoModel, dry: bool = False, indent: int = 0) -> None:
files = get_files(monorepo)
write_files(files, monorepo.get_directory(), force=True, dry=dry)
write_files(files, monorepo.get_directory(), force=True, dry=dry, indent=indent)
@mono.command()

+ 1
- 1
src/shut/commands/pkg/bump.py

@ -53,7 +53,7 @@ class PackageBumpData(VersionBumpData[PackageModel]):
return check_package(self.obj, self.args.warnings_as_errors)
def update(self) -> None:
update_package(self.obj, dry=self.args.dry)
update_package(self.obj, dry=self.args.dry, indent=1)
def get_snapshot_version(self) -> Version:
project = self.project

+ 2
- 2
src/shut/commands/pkg/update.py

@ -28,9 +28,9 @@ from shut.update import get_files
from . import pkg
def update_package(package: PackageModel, dry: bool = False) -> None:
def update_package(package: PackageModel, dry: bool = False, indent: int = 0) -> None:
files = get_files(package)
write_files(files, package.get_directory(), force=True, dry=dry)
write_files(files, package.get_directory(), force=True, dry=dry, indent=indent)
@pkg.command()

Loading…
Cancel
Save