Announcement

Collapse
No announcement yet.

Pre Commit Hook

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pre Commit Hook

    Hello All,

    I need to create a Pre Comit Script with the following Parameters.

    A typical comment must look like:
    KO/MB - CPLN555 - Add test case for xyz
    Ticket number is between the dashes. Allow "- NOSTORY -" to indicate that the changes do not need a corresponding story.

    I am fairly a newbie to scripting, Is there anyone that can help ?

    Thanks

  • #2
    This is what I came up with The regex works and was tested, what am i doing wrong with this pre-commit.

    #!/bin/sh
    REPOS="$1"
    TXN="$2"
    SVNLOOK=/usr/bin/svnlook
    regex=-\s*(?i)(\S+\d+|NOSTORY)\s*-"
    if "$SVNLOOK" log -t "$TXN" "$REPOS" | head -n1 | grep -q '-\s*(?i)(\S+\d+|NOSTORY)\s*-' ; then

    exit 0
    else
    echo "" 1>&2
    echo "Please make your commit comment start with PRODUCT-XXX" 1>&2
    exit 1
    fi

    Comment

    Working...
    X