0

I am trying to write a pre commit hook script to enforce a tag naming convention like this <application>_<project>_<version>_<iteration> using a shell script.
Can anyone guide me to a doc/link reference which I can follow and can create one. I have already gone through many links but it didn't work for me

I am trying to do something like this:

ERROR=$SVNLOOK changed $REPO -t $REV |$EGREP "^A.+?/([a-z0-9_]+)/tags/\1-[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-(dev|rc[0-9]+|final)/.*$" |$WC -l

Need help in regex(EGREP) part so that I can create it.

Montag451
  • 1,168
  • 3
  • 14
  • 30
Aman
  • 357
  • 2
  • 5
  • 17

1 Answers1

0

I can't recall will be hooks executed after pure server-side copies (and too lazy to RTFM or check it by hand), but anyway

In hook you have to use svnlook command with different subcommands

Because hooks are repository-wide your first check will be "Is it commit to /tags or to another subtree of repository" svnlook dirs-changed (try command by hand in order to see output for different revisions, in case of good OS svnlook dirs-changed |grep tags will answer on question)

In case of commit into /tags you have to get and check name of (created) subdir inside /tags. Here server-side tagging and tagging from WC give (at least for me) different results

svnlook dirs-changed

Server-side tagging

>svnlook dirs-changed z:\repo
tags/

WC-tagging

>svnlook dirs-changed z:\repo
tags/
tags/App_Main_1.0.0_2/
tags/App_Main_1.0.0_2/1/
tags/App_Main_1.0.0_2/1/2/

svnlook changed

Server-side tagging

>svnlook changed z:\repo
A   tags/App_Main_1.0.0_1/

WC-tagging

>svnlook changed z:\repo
A   tags/App_Main_1.0.0_2/
U   tags/App_Main_1.0.0_2/1/2/c.txt
U   tags/App_Main_1.0.0_2/1/b.txt
U   tags/App_Main_1.0.0_2/a.txt

and such noticeable differences are observed under identical tree within tags

>svnlook tree z:\repo
...
 tags/
  App_Main_1.0.0_1/
   1/
    2/
     c.txt
    b.txt
   a.txt
  App_Main_1.0.0_2/
   1/
    2/
     c.txt
    b.txt
   a.txt
...

I think, instead of adding some logic inside hook (but you may try to use svnlook changed | head -n 1 for both types of tags: catch only first line of output with name of created tag in it), you have to enforce strict tagging-policy "Tag only trunk's HEAD (use server-side copy)".

In this case test will be shorter and reabable, something like svnlook changed | grep -q -E REGEXP (there building REGEXP for testing convention <application>_<project>_<version>_<iteration> is your task) plus|minus some details

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • thnx 4 such a detailed explanation. I believe u want me 2 try like this – Aman May 18 '14 at 06:54
  • ERROR=`$SVNLOOK changed $REPO -t $REV |$EGREP "^A.+?/([a-z0-9_]+)/tags/\1-[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-(dev|rc[0-9]+|final)/.*$" |$WC -l` – Aman May 18 '14 at 06:55