The environment I work in now is hevily Window-ified. This is due to the
extensive use of PowerShell for the Build/Release processes and the fact the
major project is a SharePoint installation. Now that we have moved to
Subversion and have packages coming out, sometimes with only small fixes, I
decided I needed a way to be able to get some information on a package. To be
able to include this in the Build scripts I needed something in PowerShell that
would query Subversion and give me a list of comments from all commits since the
last release version. This worked out well, took a bit to figure out, but it
came out nice in the end.
function GetLog([string]$target, [int]$base_version, [int]$target_version, $relNotesDir="C:\Temp")
{
if(($relNotesDir -eq $null) -or ($relNotesDir -eq "")) {
"The " + $relNotesDir + " is empty. `n"
$relNotesDir="C:\Temp"
}
if (!(Test-Path -Path $target)) {
$target + " does not exist.`n"
"Try the $target path again, make sure it is typed correctly and exists.`n"
exit
}
if (!(Test-Path -Path $relNotesDir)) {
"The Release Notes directory " + $relNotesDir + " does not exist.`n"
"Enter an existing directory and try again.`n"
exit
}
"Looking for changes from " + $base_version + " to " + $target_version + " in " + $target
"Writing Release Notes out to " + $relNotesDir
$releaseNotes = Join-Path -Path $relNotesDir -ChildPath( "releaseNotes_" + $target_version + ".txt")
$Command = "svn.exe"
$Range = "" + $base_version + ":" + $target_version
$Params = "log",$target,"-r",$Range,"--xml"
$svnlog = [xml](& $Command $Params)
$svnlog.log.logentry | foreach {
if ( $_.revision -gt $base_version ){
$a = ( $_.revision + " : " + $_.author + " `n " + $_.msg )
$a >> $releaseNotes
}
}
}
Hope this helps someone out!
function GetLog([string]$target, [int]$base_version, [int]$target_version, $relNotesDir="C:\Temp")
{
if(($relNotesDir -eq $null) -or ($relNotesDir -eq "")) {
"The " + $relNotesDir + " is empty. `n"
$relNotesDir="C:\Temp"
}
if (!(Test-Path -Path $target)) {
$target + " does not exist.`n"
"Try the $target path again, make sure it is typed correctly and exists.`n"
exit
}
if (!(Test-Path -Path $relNotesDir)) {
"The Release Notes directory " + $relNotesDir + " does not exist.`n"
"Enter an existing directory and try again.`n"
exit
}
"Looking for changes from " + $base_version + " to " + $target_version + " in " + $target
"Writing Release Notes out to " + $relNotesDir
$releaseNotes = Join-Path -Path $relNotesDir -ChildPath( "releaseNotes_" + $target_version + ".txt")
$Command = "svn.exe"
$Range = "" + $base_version + ":" + $target_version
$Params = "log",$target,"-r",$Range,"--xml"
$svnlog = [xml](& $Command $Params)
$svnlog.log.logentry | foreach {
if ( $_.revision -gt $base_version ){
$a = ( $_.revision + " : " + $_.author + " `n " + $_.msg )
$a >> $releaseNotes
}
}
}
Hope this helps someone out!
No comments:
Post a Comment