bash - SVN log - get only revisions with pattern in comments -


I am trying to create a simple Bash script which verifies which version does not contain any comments.

For example:

  ----------------------------- ---- --------------------------------------- R272876 | User | 2014-10-30 11:15:06 +0000 (Qi, 30 out 2014) | 1 line PATTERN-17278: My comment ------------------------------------------ -------- ---------------------- R272877 | User | 2014-10-31 12:06:41 +0000 (Sex, 31 Out 2014) | 1 line my problematic revision --------------------------------------------- --------------------------- R273529 | User | 2014-10-20 17:45:36 +0000 (Seg, 20 November 2014). 2 lines PATTERN-17297: Arro no Angulo do Vitter volciled ------------------------------------ - ---------------------------------- R273797 | User | 2014-10-14 11:35:05 +0000 (Ter, 4th of November 2014). 1 line other problematic modification --------------------------------------------- --------------------------- R274096 | User | 2014-08-26 11:18:31 +0000 (or, 5th November 2014) | 1 line and second  

How do I easily print modifications like R272877, R273797 and R274096 in the list? First, let's define a shell variable that has a dashed line in which the SVN log separates entries. Is:

  RS = '\ n ----- ---------------------------- ---------------------- ----------------- ' 

Now, we can print all the log entries that are not in pattern :

  svn logs. Alternatively, if you only want log entries which  do  are included in the  pattern , then use: 

  svn log | Oak-v "rs = $ rs" / / pattern / {print rs, $ 0} ''  

how it works

  • -V "RS = $ RS"

    awk divides its input into records and reads in one record at a time. Here, we define the record separator how SVN uses to isolate log entries.

  • ! / Pattern / {Print RS, $ 0}

    awk Input the input through each record inherently. Looks like a record which is not in the pattern where pattern can be a regular expression, an exclamation point, ! , "No" means the records that meet this criteria are printed. Print RS, $ 0 tells the awk to print the record separator, and then the contents of the entry of this entry.

The version of my subdivision uses 72 dashes as a record separator. I do not know that it is subject to change from version to version. If so, you may need to adjust the definition of RS appropriately.

example

log , it prints all records where PATTERN-17278 :

 < Code> $ awk -v "RS = $ RS" '! / PATTERN-17278 / {print rs, $ 0} 'log ------------------------------------ ----- ---------------------------- R272877 | User | 2014-10-31 12:06:41 +0000 (Sex, 31 Out 2014) | 1 line my problematic revision --------------------------------------------- ---------------------------  

Optional output: Return only the amendment numbers

< P> The record number is the first object after the record separator. To print modification numbers only, use:

  svn logs | Using sample input as an example [before updating question]:  
 "RS = $ RS"! / Pattern / {print $ 1} ''  

$ awk -v "RS = $ RS"! / PATTERN-17278 / {print $ 1} 'log2 r2728

use of a variable pattern

  awk -v "RS = $ RS" -VP = 'PATTERN-17278 | PATTERN-17297 '' $ 0! ~ P {Print $ 1} 'log3 r272877 r273797 r274096  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -