1753784 Members
7182 Online
108799 Solutions
New Discussion

Re: Perl or shell script

 
allanm77
Frequent Advisor

Perl or shell script

Hi!

 

Time and again I have to tag my app configs. I want a script which can automate this process.

 

1)First I do a svn info to get a list of configs which are pointing to BRANCHES/TAGS

 

svn info * |grep URL

 

URL: http://svn.com/qbo/library/General/GeneralConfiguration/BRANCHES/2011-05
URL: http://svn.com/qbo/library/Core/CoreConfiguration/BRANCHES/2011-05
URL: http://svn.com/qbo/library/signup/signupProcessorConfiguration/BRANCHES/2011-05
URL: http://svn.com/qbo/library/signup/signupStatusConfiguration/BRANCHES/2011-05
URL: http://svn.com/qbo/library/signup/signupingConfiguration/BRANCHES/2011-05

URL: http://svn.com/qbo/library/web/WebConfiguration/TAGS/2011-05-1

 

2)Now I basically find out if there are existing TAGS for the these configs with the same TAG as that I am hoping to create .

 

3) Thirdly I create them -

 

svn cp http://svn.com/qbo/library/Core/CoreConfiguration/BRANCHES/2011-05 http://svn.com/qbo/library/Core/CoreConfiguration/TAGS/2011-05-1

....

 

IF TAGS/2011-05-1 exists then I create a TAGS/2011-05-2 tag.

 

I want to automate this in a way so that the script can check the existence of a tag and if it does not exists then create one or increment to the next number if there is already one created.

 

Thanks,

Allan.

 

4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: Perl or shell script

Hi:

 

See if this fits your needs:

 

#!/usr/bin/perl
use strict;
use warnings;
my $tag = shift or die "tag to match expected\n";
while (<>) {
    print;
    next unless m{$tag};
    chomp;
    if ( m{^.+\d\d\d\d\-\d\d$} ) {
        print $_ . "-1\n";
    } elsif ( m{(^.+\d\d\d\d\-\d\d\-)(\d+)$} ) {
        print $1 . ($2+1) . "\n";
    }
}
1;

...run as:

 

# ./fixup 2011-05 file

 

...or :

 

# svn info * | ./fixup 2011-05

 

That is, the script expects a tag to match (e.g. 2011-05) and a file or STDIN stream.  Use your data to verify that you get what you want.

 

Regards!

 

...JRF...

 

allanm77
Frequent Advisor

Re: Perl or shell script

Hi JRF,

 

Would this suffice to create a new TAG out of svn info if the output has a TAG listed out instead of BRANCHES - 

 

URL: http://svn.com/qbo/library/web/WebConfiguration/TAGS/2011-05-1

 

svn cp http://svn.com/qbo/library/web/WebConfiguration/BRANCHES/2011-05  http://svn.com/qbo/library/web/WebConfiguration/TAGS/2011-05-2

 

 

Thanks,

Allan.

James R. Ferguson
Acclaimed Contributor

Re: Perl or shell script

HI (again) Allan:

 


@allanm77 wrote:

 

Would this suffice to create a new TAG out of svn info if the output has a TAG listed out instead of BRANCHES - 

...

It isn't clear to me exactly what you want to match and what you want to manufacture.  The suggestion I made thus far allows you to match by passing an argument like "2011-05" or "TAGS/2011-05" or "BRANCHES/2011-05" and incrementing any suffix found.

 

The scriptlet I offered prints out the old and newly manufactured information.  Do you want it to issue the actual 'svn cp'?

 

Please provide a sample input and expected output (given that the output may be one or more commands).  Specify, too what *you* mean by "match".

 

Regards!

 

...JRF...

James R. Ferguson
Acclaimed Contributor

Re: Perl or shell script

Hi (again) Allan:

 

By the way, if you are/were known as simply "Allanm" in the old ITRC, you have several un-evaluated (scored/kudoed) threads from just before the migration:

 

http://h30499.www3.hp.com/t5/user/viewprofilepage/user-id/1082079

 

Please consider revisiting them as anyone can now assign kudos.

 

Regards!

 

...JRF...