Skip to main content
added 116 characters in body
Source Link

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

I want to pick the hash of the commit where version changed to a certain value (1.2.0 in the regex I wrote).

Obviously, this being the log of all the commits done on a certain repository, there may be more than one commit as well.

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

Obviously, this being the log of all the commits done on a certain repository, there may be more than one commit as well.

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

I want to pick the hash of the commit where version changed to a certain value (1.2.0 in the regex I wrote).

Obviously, this being the log of all the commits done on a certain repository, there may be more than one commit as well.

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

added 125 characters in body
Source Link

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

Obviously, this being the log of all the commits done on a certain repository, there may be more than one commit as well.

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

Obviously, this being the log of all the commits done on a certain repository, there may be more than one commit as well.

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

added 810 characters in body
Source Link

Filter git log of pom.xml using regex with grep/perl

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

Filter git log of pom.xml using regex

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

Filter git log of pom.xml using regex with grep/perl

I'd like to filter the content of a log of a pom.xml file using a regex.

I created it on regexr and it works using PCRE; this is my regex:

commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)

I then tried to run with the following commands:

git log --full-history -p pom.xml | grep -P "commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)"

and

git log --full-history -p pom.xml | perl -nle 'print \$1 if /commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)/'

but neither of them worked (nothing seems to match).

I'm surely missing something, but I cannot figure out what.

EDIT:

To clarify, this is an example of git log:

commit a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f
Author: Author <[email protected]>
Date:   Wed Mar 30 15:04:29 2022 +0100
 
    commit message
 
diff --git a/pom.xml b/pom.xml
index 93df07e..5f82fd2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.organization.project</groupId>
        <artifactId>ProjectName</artifactId>
-       <version>1.1.1</version>
+       <version>1.2.0</version>
        <name>ProjectName</name>
        <description>Description of project</description>

Using the aforementioned regex on this input should output the commit hash:

a1357f4e1cb2c34aa1a1357f4e1cb2c34aa1471f

This is what actually happens using regexr.

Source Link
Loading