Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support replacing a placeholder string only once during the next version bump #809

Open
edgarrmondragon opened this issue Aug 7, 2023 · 4 comments
Labels
issue-status: wait-for-implementation maintainers agree on the bug / feature type: feature A new enhacement proposal

Comments

@edgarrmondragon
Copy link
Contributor

edgarrmondragon commented Aug 7, 2023

Description

I'm using Sphinx to document my Python project, which has a versionadded and versionchanged directives for rendering the version a feature was added.

For example:

def a_new_function():
  """A simple function.

  .. versionadded:: 0.1.0
  .. versionchanged:: 0.1.1  (could also be 0.2.0 if some features landed before the release)
  Return float.
  """
  return 1.0

The problem is, I don't always know what the next version will be, which most of the time is either a patch or a minor bump, so I'd like to configure commitizen with custom strings that it can change and replace with the new version in the project tree, so I can do something like:

def a_new_function():
  """A simple function.

  .. versionadded:: 0.1.0
  .. versionchanged:: NEXT_VERSION
  Return float.
  """
  return 1.0

without having to think what the next version will be.

Possible Solution

Perhaps something like this:

[tool.commitizen]
replace_with_version = "NEXT_VERSION"

Additional context

In the past I've used a similar tool called Changie that supports a replacements option:

# .changie.yaml
- path: src/mylib/client.py
  find: "NEXT_VERSION"
  replace: "{{.VersionNoPrefix}}"

Additional context

No response

@woile
Copy link
Member

woile commented Aug 8, 2023

Do you want versionchanged:: 0.1.1 to be updated on every new release?

@edgarrmondragon
Copy link
Contributor Author

edgarrmondragon commented Aug 8, 2023

Do you want versionchanged:: 0.1.1 to be updated on every new release?

Not really. Only following the first cz bump after a new versionchanged:: NEXT_VERSION is added to the codebase.

In fact, there could be multiple versionchanged for each function, class, etc. For example:

def a_new_function():
  """A simple function.

  .. versionadded:: 0.1.0

  .. versionchanged:: 0.1.1
  Return float.

  .. versionchanged:: 0.2.0
  Return 2.0 if FEATURE_FLAG is set.
  """
  if FEATURE_FLAG:
    return 2.0
  return 1.0

EDIT: I've update the issue title to better reflect the feature I'm describing 🙂

@edgarrmondragon edgarrmondragon changed the title Support replacing a placeholder string when bumping the version Support replacing a placeholder string only once during the next version bump Aug 8, 2023
@woile
Copy link
Member

woile commented Aug 8, 2023

I like the idea, what do you think @noirbizarre @Lee-W ?

What I don't like from the example is that once you update with the new version, this block:

# .changie.yaml
- path: src/mylib/client.py
  find: "NEXT_VERSION"
  replace: "{{.VersionNoPrefix}}"

is meaningless, but it's more efficient than looking up all the files

@Lee-W
Copy link
Member

Lee-W commented Aug 9, 2023

I'm good with this feature 👍

@Lee-W Lee-W added the type: feature A new enhacement proposal label Aug 9, 2023
@Lee-W Lee-W added issue-status: wait-for-implementation maintainers agree on the bug / feature and removed issue-status: wait-for-response labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-status: wait-for-implementation maintainers agree on the bug / feature type: feature A new enhacement proposal
Projects
None yet
Development

No branches or pull requests

3 participants