c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 134 forks source link

Add search with regex support. #218

Open alexgracianoarj opened 3 years ago

alexgracianoarj commented 3 years ago

search_regex =

default: none

Regex to search for the string to be replaced in the file. Support {current_version} template string (e.g. (?<=version='){current_version}(?=')). If search_regex is defined, the search template string will be ignored in the section.

[bumpversion]
current_version = 2.4.5

[bumpversion:file:pom.xml]
search_regex = (?<=test-app-java</artifactId>\n\s{4}<version>){current_version}(?=</version>)
search = <version>{current_version}</version> ; will be ignored
replace = {new_version}

Example of use, when the application version is the same as some dependencies (java application, pom.xml):

    ...
    <artifactId>test-app-java</artifactId>
    <version>2.4.5</version>
    <packaging>jar</packaging>
    ...
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.4.5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    ...
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>2.4.5</version>
                </plugin>
            </plugins>
        </pluginManagement>
    ...

Also available as --search-regex

eduzen commented 3 years ago

Hi @alexgracianoarj, could I help you in somehow with this? maybe we can add some description to make it more clear?

florisla commented 3 years ago

Hi,

The example in the README (MyProject==) does not make clear why you would use this instead of regular search.

Could you elaborate a bit (in this issue) what you are using this for?

alexgracianoarj commented 3 years ago

Hi @eduzen and @florisla, i have update the README file and description.