CleanCode logo
sitemap
SEARCH:

CleanCode PowerShell Libraries v1.2.08 API: CleanCode » SvnTools » Get-IssueTrackerLogPattern

Get-IssueTrackerLogPattern

NAME

Get-IssueTrackerLogPattern

SYNOPSIS

Returns the TortoiseSVN "bugtraq:logregex" property of the closest parent to the specified item.

SYNTAX

Get-IssueTrackerLogPattern [[-Path] <String[]>] [<CommonParameters>]

DESCRIPTION

TortoiseSVN provides a very handy feature to add live links on your bug IDs in your commit messages connecting back to your bug tracking system. This works with any bug tracking system that has a web interface. (For example, I set up one system to point to a private installation of Jira and another to point to the publicly accessible SourceForge issue tracker.)

No additional effort is required to create these links other than to be sure to put your bug IDs in the log message into the correct format. Furthermore, if you have been using the same standard format previously (without the convenience of links) it is automatically retroactive! Once you or your admin configures Subversion with the "bugtraq" properties, all of your prior entries will also automatically display these links.

TortoiseSVN provides a couple different ways to let you specify the format of your bug ID. I prefer the method that uses regular expressions which, though a bit more complicated, provides much more expressive power. So with this method, the format is defined by a regular expression contained in the "bugtraq:logregex" property of the current folder. If it isn't there, the property is automatically inherited by child folders unless explicitly overridden.

This is different from standard Subversion properties (e.g. "svn:ignore") which must explicitly be attached to each folder in a hierarchy (either manually or by auto-prop rules) to be recognized. The "bugtraq" properties are implicitly inherited--they do not need to be attached unless some descendant wishes to use a different value.

There is actually one reason you might want to propagate the same property value to descendants. If you put a "bugtraq" property on a project root it will apply to the entire project as long as you checkout from the root. If you checkout a portion of your tree below the root, though, the property will not exist.

So Get-IssueTrackerLogPattern traverses up the file tree until it finds the closest ancestor that defines a "bugtraq" property. This is useful, for instance, in case different projects have adopted different formats for recognizing bug IDs. Get-IssueTrackerLogPattern reports the format for a specified file or folder by walking up the tree until it finds the closest parent having the "bugtraq:logregex" pattern defined. If it crawls to the working copy root finding no pattern, it reports "-none-". Use the common -Verbose parameter to see the treewalk.

As the TortoiseSVN documentation indicates, this pattern is used by the TortoiseSVN project itself:

        [Ii]ssues?:?(\s*(,|and)?\s*#\d+)+
        (\d+)

Quoting the manual, "The first expression picks out 'issues #23, #24 and #25' from the surrounding log message. The second regex extracts plain decimal numbers from the output of the first regex, so it will return '23', '24', and '25' to use as bug IDs."

That is all true, but that pattern will also match "issues #23, #24 and#25" (note the missing space after the "and") and it will *not* match "issues #23, #24, and #25" (i.e. with an additional comma after the penultimate entry). This regex alleviates those issues:

        [Ii]ssues?:?(\s*(,|,?\s*and\s)?\s*#\d+)+

PARAMETERS

-Path <String[]>
        Specifies a path to one or more locations.
        The default location is the current directory (.).

        Required?                    false
        Position?                    1
        Default value                .
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  true

<CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, see 
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 

INPUTS

System.String. You can pipe one or more path strings to Get-IssueTrackerLogPattern.

OUTPUTS

String representing the log pattern for the input, or "-none-".

NOTES



        This function is part of the CleanCode toolbox
        from http://cleancode.sourceforge.net/.

        Since CleanCode 1.1.02.

EXAMPLES


-------------------------- EXAMPLE 1 --------------------------

PS>Get-IssueTrackerLogPattern

Returns the log pattern, if any, for the current directory.

-------------------------- EXAMPLE 2 --------------------------

PS>Get-IssueTrackerLogPattern -Verbose

Returns the log pattern, if any, for the current directory and displays the path of each item from the current directory up to the last folder that is still a Subversion folder.

-------------------------- EXAMPLE 3 --------------------------

PS>"Xyz*" | Get-IssueTrackerLogPattern

Returns the log pattern, if any, for each item in the current directory beginning with "Xyz".

RELATED LINKS

This documentation set was created with CleanCode's DocTreeGenerator.

Valid XHTML 1.0!Valid CSS!Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads
Copyright © 2001-2015 Michael Sorens • Contact usPrivacy Policy
Usage governed by Mozilla Public License 1.1 and CleanCode Courtesy License
CleanCode -- The Website for Clean DesignRevised 2015.12.16