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 dates in replace #133

Open
Gallaecio opened this issue Feb 28, 2020 · 8 comments
Open

Support dates in replace #133

Gallaecio opened this issue Feb 28, 2020 · 8 comments

Comments

@Gallaecio
Copy link

In order to set the current date in the last release notes entry, where we use a ? in unknown digits of the release date, I would like to use something like:

[bumpversion:file:docs/news.rst]
search = (?<=\()[\d?]{4}-[\d?]{2}-[\d?]\?(?=\))
replace = {now:%Y-%m-%d}

Would it be possible to add now support to replace, or support this scenario some other way?

@laurent-laporte-pro
Copy link

In Python projects, the support of date (current date with datetime.date.today or user-defined date) would be interesting and in harmony with the package metadata which pydoc (and the help function) can display.

For instance, if your package contains:

__version__ = "0.11.0"
__date__ = "2020-06-10"
__author__ = "Mr Robot <[email protected]>"
__credits__ = "(c) F. Society"

The help function would display:

[...]

VERSION
    0.11.0

DATE
    2020-06-10

AUTHOR
    Mr Robot <[email protected]>

CREDITS
    (c) F. Society

That way, a developper can easily have the version number and the date of your package.

So, it wold be great if bump2version could update the version number and the release date at the same time).

Question: does bump2verion support pre-/post-release hook ?

@deliberist
Copy link

I want to add that I would also like this feature, in particular to update non-Python files. Specifically, manpages. For example, I would like have this in my .bumpversion.cfg:

[bumpversion:file:man/man1/xdg-env.1]
search = "\d\d\d\d \w\w\w \d\d" "v{current_version}"      ; I could certainly use a better regex...
replace = "{now:%Y %b %d}" "v{new_version}"

It should match this line in my man/man1/xdg-env.1:

.TH man 1 "2020 Jun 13" "v2.3.2" "xdg-env man page"

In the mean time, I have to manually update the date in my manpages. Obviously that's not difficult, but it is a step I tend to forget when I releasing a new version of my code.

@AndreaCensi
Copy link

What do people use to achieve this without bump2version? Just an ad-hoc solution, or is there a packaged alternative?

@Gallaecio
Copy link
Author

I do it manually in a commit right before running bump2version.

@DXist
Copy link

DXist commented Jan 9, 2023

Dates are useful to maintain a Changelog in Keep A Changelog format.

With my particular approach I generate a version like 2023.1.0 and add the current date like 2023-01-09

@MattF-NSIDC
Copy link

I just found that this is supported via regex searches in bump-my-version. which looks to be this project's actively-maintained successor.

#268
https://github.com/callowayproject/bump-my-version/pull/39/files

@Gallaecio
Copy link
Author

I appreciate being told about bump-my-version, but I fail to see how it solves this issue, at least at the moment. The problem is being able to get the current date as a replacement, not the use of regular expressions.

@MattF-NSIDC
Copy link

MattF-NSIDC commented Aug 21, 2023

This functionality requires one or two pieces, depending on what you want to do. If you want to change a date from one date to the current date, e.g. updating citation metadata with a release date, you need (1) find the line with the old date (which, in the original post of this thread, you demonstrated with a regex); (2) replace with the current date.

bump2version can do (2), but not (1), so it can be used for cases like inserting (not replacing) a date in a changelog. Before migrating to bump-my-version, my current project was achieving this with bump2version.

bump-my-version can do both (1) and (2), which enabled us to implement the citation metadata use case after migrating away from bump2version. This looks a lot like your example in the original post!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants