diff --git a/pyproject.toml b/pyproject.toml
index fbc2daa..a6bad8c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -43,20 +43,33 @@ jinja2 = "^3.1.4"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
-# Auto-generated version in build, based on tag or commit.
-# https://sam.hooke.me/note/2023/08/poetry-automatically-generated-package-version-from-git-commit/
+# Auto-generated version for builds based on git tag or commit.
+# Preferred styles of versioning (PEP 440 compliant):
+#
+# 1.2.3 (stable release)
+# 1.2.3a4 (pre-release, no dash or dots)
+# 1.2.3rc1 (release candidate)
+# 1.2.3.dev4+abcdef12 (development build, .dev for dev releases and +commit hash)
+#
+# Tags with a "v" prefix (e.g., v1.2.3) or additional dots (e.g., v1.2.3.rc1) are recognized
+# but normalized to the preferred style for distribution.
+# See: https://sam.hooke.me/note/2023/08/poetry-automatically-generated-package-version-from-git-commit/
[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
-pattern = "^v?(?P\\d+\\.\\d+\\.\\d+)(-?((?P[a-zA-Z]+)\\.?(?P\\d+)?))?"
+pattern = "^v?(?P\\d+\\.\\d+\\.\\d+)(-?((?P[a-zA-Z]+)\\.?(?P\\d+)?))?"
format-jinja = """
{%- if distance == 0 -%}
{{- base -}}
+ {%- if stage -%}
+ {{ stage }}{{ revision | default("") }}
+ {%- endif -%}
{%- else -%}
{{- base }}.dev{{ distance }}+{{commit}}
{%- endif -%}
"""
+
[tool.poetry.scripts]
repren = "repren:main"
diff --git a/repren/repren.py b/repren/repren.py
index c520123..4cb8880 100755
--- a/repren/repren.py
+++ b/repren/repren.py
@@ -121,7 +121,7 @@
[repren.py](https://raw.githubusercontent.com/jlevy/repren/master/repren/repren.py) script
somewhere convenient and make it executable.
-## Try it
+## Try It
Let's try a simple replacement in my working directory (which has a few random source
files):
@@ -409,12 +409,6 @@ def multi_replace(
# --- Case handling (only used for case-preserving magic) ---
-# TODO: Could handle dash-separated names as well.
-
-# FooBarBaz -> Foo, Bar, Baz
-# XMLFooHTTPBar -> XML, Foo, HTTP, Bar
-_camel_split_pat1 = re.compile("([^A-Z])([A-Z])")
-_camel_split_pat2 = re.compile("([A-Z])([A-Z][^A-Z])")
_name_pat = re.compile(r"\w+")
@@ -424,6 +418,7 @@ def _split_name(name: str) -> Tuple[str, List[str]]:
Split a CamelCase or underscore-formatted name into words.
Return separator and list of words.
"""
+ # TODO: Could handle dash-separated names as well.
if "_" in name:
# Underscore-separated name
return "_", name.split("_")
diff --git a/tests/tests.sh b/tests/tests.sh
index 29201c4..5850b2c 100755
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -22,7 +22,7 @@ expect_error() {
echo "(got expected error: status $?)"
}
-# A trick to do ls portably, showing just files and types.
+# A trick to do ls portably, showing just files, types, and permissions.
# Macos appends an @ to permissions, so we strip it.
ls_portable() {
ls -lF "$@" | tail -n +2 | awk '{gsub(/@/, "", $1); print $1, $NF}'