I'm looking for a part-time remote job.

Hire me


I'm the author of:

Mastering Redmine is a comprehensive guide with tips, tricks and best practices, and an easy-to-learn structure.

Check the book's project or

Buy the book

Social pages of the book:

By buying this book you also donate to Redmine (see this page).


Follow me:

Can I get an example script for post-create.sh?

Added by Jim McAleer over 11 years ago

When the repository is created I would like it to automatically create /trunk /branches /tags directories with svn.

I’ve tried the following. I guess I just don’t understand how the commands are suppose to be put in. Thanks for the help in advance. I’ve test the command with a hardcoded path and it works. I bet it’s a syntax thing. I’ll keep trying.

here’s my post-create.sh


#! /bin/sh

SCM_REPO_PATH=$1
SCM_TYPE=$2
SCM_PROJECT=$3

SCM_REPO_NAME=$(basename $SCM_REPO_PATH)
SCM_REPO_ROOT=$(dirname $SCM_REPO_PATH)

case "$SCM_TYPE" in
    svn)
        svn mkdir --parents file:$SCM_REPO_NAME"/{trunk,tags,branches}" -m "initial dir creation" 
        ;;
    git)
        ;;
    mercurial)
        ;;
    bazaar)
        ;;
    *)
        echo "SCM not supported: $SCM_TYPE" >&2
        ;;
esac

exit 0

Replies (4)

RE: Can I get an example script for post-create.sh? - Added by Andriy Lesyuk over 11 years ago

Hi, Jim!

The script looks to be fine... Maybe you wanted to use $SCM_REPO_ROOT instead of $SCM_REPO_NAME?

RE: Can I get an example script for post-create.sh? - Added by Jim McAleer over 11 years ago

That didn’t seem to work either. It just look like it’s not getting fired. I’ve searched the logs and don’t see anything related to it.

RE: Can I get an example script for post-create.sh? - Added by Andriy Lesyuk over 11 years ago

To ensure that the script is running you can add, e.g.:

touch /tmp/script-is-running

below:

#!/bin/bash

By the way, there should be no space between #! and /bin/bash and this should be the first line...

RE: Can I get an example script for post-create.sh? - Added by igor kattar over 11 years ago

Here, on FreeBSD 9.0, I’d made these changes, now the directories are created successfully.

#!/bin/sh
SCM_REPO_PATH=$1
SCM_TYPE=$2
SCM_PROJECT=$3
case "$SCM_TYPE" in
    svn)
    svn mkdir --parents file://$SCM_REPO_PATH/trunk file://$SCM_REPO_PATH/tags file://$SCM_REPO_PATH/branches -m "Initial directories created" 
    ;;
    git)
    ;;
    mercurial)
    ;;
    bazaar)
    ;;
    *)
    echo "SCM not supported: $SCM_TYPE" >&2
    ;;
    esac
exit 0

Guess there’s something wrong in basename and dirname lines running on FreeBSD, btw, I don’t think that the svn mkdir command accept the same syntax as the sh mkdir command...

    (1-4/4)

    Terms of use | Privacy policy