Blame Scripts/Bash/Functions/cli_getThemeName.sh

4c79b5
#!/bin/bash
4c79b5
#
fa8567
# cli_getThemeName.sh -- This function interprets the current
fa8567
# absolute path ---defined in action value variable--- to extract the
fa8567
# theme name from it. If theme name is found on absolute path, this
fa8567
# function returns an empty string. 
63bc52
#
72c8a5
# Copyright (C) 2009-2011  Alain Reguera Delgado
4c79b5
# 
4c79b5
# This program is free software; you can redistribute it and/or
4c79b5
# modify it under the terms of the GNU General Public License as
4c79b5
# published by the Free Software Foundation; either version 2 of the
4c79b5
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function cli_getThemeName {
4c79b5
fa8567
    # Initialize regular expression pattern.
fa8567
    local PATTERN=''
fa8567
fa8567
    if [[ $ACTIONVAL =~ '^/home/centos/artwork/trunk/.*$' ]];then
fa8567
fa8567
        # Define theme name for trunk development line.  There is no
fa8567
        # enumeration schema for themes stored under trunk development
fa8567
        # line. Inside trunk development line, theme names are stored
fa8567
        # in directories immediatly under Themes/Motifs/ directory and
fa8567
        # and can be named using letters and numbers.
fa8567
        PATTERN='^.+/Identity/Themes/Motifs/([A-Za-z0-9]+)/.+$'
fa8567
fa8567
    elif [[ $ACTIONVAL =~ '^/home/centos/artwork/branches/.*$' ]];then
4c79b5
fa8567
        # Define theme name for branches development line.  Branch
fa8567
        # enumeration starts at number one and increments one unit
fa8567
        # each time a new branch is created from the same trunk
fa8567
        # development line.  If a branch is created from another brach
fa8567
        # then a new directory is created inside the source branch,
fa8567
        # using the same enumeration schema.  So, we may end up with
fa8567
        # paths like branches/.../Themes/Motifs/Flame/1,
fa8567
        # branches/.../Themes/Motifs/Flame/1/1,
fa8567
        # branches/.../Themes/Motifs/Flame/1/2,
fa8567
        # branches/.../Themes/Motifs/Flame/2,
fa8567
        # branches/.../Themes/Motifs/Flame/2/1, and so on.  In all
fa8567
        # previous examples the theme name holds the branch
fa8567
        # enumeration schema too.
fa8567
        PATTERN="^.+/Identity/Themes/Motifs/(([A-Za-z0-9]+)(/${RELEASE_FORMAT})+)/.+$"
fa8567
fa8567
    elif [[ $ACTIONVAL =~ '^/home/centos/artwork/tags/.*$' ]];then
fa8567
fa8567
        # Define theme name for tags frozen lines.  Branch enumeration
fa8567
        # starts at number zero and increments one unit each time a
fa8567
        # new tab is created from the same branch development line.
fa8567
        # Tags are never created from trunk, if you need to create a
fa8567
        # tag from trunk, you need to create a branch first and later
fa8567
        # a tag. In contrast with branches enumeration schema, tags
fa8567
        # enumeration schema uses dots. So, we may end up with paths
fa8567
        # like tags/.../Themes/Motifs/Flame/1.0,
fa8567
        # tags/.../Themes/Motifs/Flame/1.1.0,
fa8567
        # tags/.../Themes/Motifs/Flame/1.2.0,
fa8567
        # tags/.../Themes/Motifs/Flame/2.0,
fa8567
        # tags/.../Themes/Motifs/Flame/2.1.0, and so on. In all
fa8567
        # previous examples the theme name holds the branch
fa8567
        # enumeration schame too.
fa8567
        PATTERN="^.+/Identity/Themes/Motifs/(([A-Za-z0-9]+)(\.${RELEASE_FORMAT})+)/.+$"
fa8567
fa8567
    else
fa8567
        cli_printMessage "`gettext "The working copy parent directory structure is incorrect."`" 'AsErrorLine'
fa8567
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
4c79b5
    fi
4c79b5
63bc52
    # Print theme name to standard output.
fa8567
    if [[ $PATTERN != '' ]];then
fa8567
        echo $ACTIONVAL | sed -r "s!${PATTERN}!\1!"
fa8567
    fi
63bc52
4c79b5
}