Open tjanez opened 4 years ago
Hey @tjanez, thanks for using Punch. Your request makes a lot of sense to me, let me think about it, and I will add the feature
Hey @tjanez, thanks for using Punch. Your request makes a lot of sense to me, let me think about it, and I will add the feature
@lgiordani, thanks for such a quick response and thanks for considering this!
Hi @tjanez. I worked a bit on this request, and found out that it can't be easily implemented. The problem is that in Python you can't load a module, change it, and save it back to the disk. Indeed, the current way I use to create the file punch_version.py is
with open(version_filepath, 'w') as f:
for key, part in self.parts.items():
f.write("{0} = {1}\n".format(key, repr(part.value)))
There might be a simple solution, though. I might add a configuration value that is the text content of the file punch_version.py, something like (punch_config.py)
HEADER = """
# Punch version file.
# It contains the current version of the project.
# For more information, see: https://punch.readthedocs.io/.
"""
and add that text to the file punch_version.py every time I recreate it. What do you think about this? It might solve your issue without requiring too much code. Let me know!
Hey!
First of all, thanks for creating this great tool. I've been successfully using it for a while.
I have a small request, namely, to stop overwriting the whole
punch_version.py
file after performing a version bump.The reason I would like this is that I would like to have a comment at the top of
punch_version.py
explaining what this file is and where to find more information since this file is usually in a repository's top-level directory and developers/users will frequently see it and wonder what it is and what it does.Here is an example
punch_version.py
I would like to have (and retain after bumping):Full example/reproducer:
And the output I get: