mirror of
https://github.com/davidism/modify-repos.git
synced 2025-07-07 19:35:34 +00:00
rewrap body message
This commit is contained in:
parent
f01a6b0097
commit
63d983afcf
2 changed files with 19 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import typing as t
|
||||
from contextlib import chdir
|
||||
from functools import cached_property
|
||||
from inspect import isclass
|
||||
|
@ -11,6 +12,7 @@ import click
|
|||
|
||||
from modify_repos.cmd import echo_cmd
|
||||
from modify_repos.cmd import run_cmd
|
||||
from modify_repos.wrap import wrap
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
|
@ -91,10 +93,12 @@ class Script:
|
|||
branch: str
|
||||
title: str
|
||||
body: str
|
||||
target: str = "main"
|
||||
branch: str
|
||||
|
||||
def __init__(self, orgs: list[str], push: bool) -> None:
|
||||
def __init_subclass__(cls, **kwargs: t.Any) -> None:
|
||||
super().__init_subclass__(**kwargs)
|
||||
cls.body = wrap(cls.body, width=72)
|
||||
|
||||
def __init__(self, push: bool) -> None:
|
||||
self.clones_dir: Path = Path("clones")
|
||||
self.push = push
|
||||
|
||||
|
|
12
src/modify_repos/wrap.py
Normal file
12
src/modify_repos/wrap.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import textwrap
|
||||
from inspect import cleandoc
|
||||
|
||||
|
||||
def wrap(text: str, width: int = 80) -> str:
|
||||
"""Wrap a multi-line, multi-paragraph string."""
|
||||
return "\n\n".join(
|
||||
textwrap.fill(p, width=width, tabsize=4, break_long_words=False)
|
||||
for p in cleandoc(text).split("\n\n")
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue