summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/CruiseControlSourceControl.ps196
-rw-r--r--tools/ccbootstrap.cmd1
-rw-r--r--tools/ccnet.config41
3 files changed, 138 insertions, 0 deletions
diff --git a/tools/CruiseControlSourceControl.ps1 b/tools/CruiseControlSourceControl.ps1
new file mode 100644
index 0000000..a3d5a63
--- /dev/null
+++ b/tools/CruiseControlSourceControl.ps1
@@ -0,0 +1,96 @@
+param([switch]$offline)
+
+[void] [Reflection.Assembly]::LoadWithPartialName("System.Web")
+
+function SafeXml($value) {
+ [Web.HttpUtility]::HtmlEncode($value)
+}
+
+function Get-Modifications($fromDate, $toDate, $gitRepo) {
+ $commitRegex = [regex]"commit (\w+)"
+ $authorRegex = [regex]"Author:\s*(.+) <(.+)>"
+ $dateRegex = [regex]"Date:\s*([^ ]+) ([^ ]+) ([^ ]+)"
+ $commentRegex = [regex]"(?: (.+))|(?:^\s*$)"
+ $fileRegex = [regex]"^(\S.+)"
+
+ Push-Location $gitRepo
+ # this should just be git fetch, and then look at the log on the remote branch.
+ # [void] (git fetch)
+ if (!$offline) { [void] (git pull) }
+ # reverse dates because CruiseControl gives them in reverse order
+ $gitlog = git log "--since=$toDate" "--until=$fromDate" "--date=iso" "--name-only"
+ @"
+<?xml version="1.0" encoding="utf-8"?>
+<ArrayOfModification>
+"@
+
+ $i = 0
+ while($i -le $gitlog.length) {
+ $m = $commitRegex.match($gitlog[$i++])
+ if ($m.success) {
+ $changeNumber = $m.groups[1].value
+ $m = $authorRegex.match($gitlog[$i++])
+ $username, $email = $m.groups[1].value, $m.groups[2].value
+ $m = $dateRegex.match($gitlog[$i++])
+ $date, $time, $timezone = $m.groups[1].value, $m.groups[2].value, $m.groups[3].value
+ [void] ($comment = New-Object Text.StringBuilder)
+ while(($m = $commentRegex.match($gitlog[++$i])).success) {
+ [void]$comment.AppendLine($m.groups[1].value)
+ }
+ $comment.length -= 2
+ $files = @()
+ while(($m = $fileRegex.match($gitlog[++$i])).success) {
+ $files += $m.groups[1].value
+ }
+ @"
+ <Modification>
+ <ChangeNumber>$(SafeXml($changeNumber))</ChangeNumber>
+ <Comment>$(SafeXml($comment))</Comment>
+ <EmailAddress>$(SafeXml($email))</EmailAddress>
+"@
+ foreach($file in $files) { @"
+ <FileName>$file</FileName>
+"@
+ }
+@"
+ <ModifiedTime>$(SafeXml("$($date)T$time$timezone"))</ModifiedTime>
+ <UserName>$(SafeXml($username))</UserName>
+ </Modification>
+"@
+ }
+ while(!$commitRegex.match($gitlog[$i]) -and $i -le $gitlog.length) {
+ Write-Host "There: " $gitlog[$i]
+ $i++
+ }
+ }
+
+ @"
+</ArrayOfModification>
+"@
+ Pop-Location
+}
+
+function Get-Source($workingDirectory, $date, $gitRepo, $branch) {
+ Push-Location $gitRepo
+ if (!$offline) { git pull }
+ # we don't yet support syncing to anything other than the tip
+ #git checkout "$($branch)@{$date}"
+ Pop-Location
+}
+
+function Set-Label($label, $date, $gitRepo) {
+ Push-Location $gitRepo
+
+ Pop-Location
+
+ throw "Not supported yet."
+}
+
+
+$op = $Args[0]
+switch($op) {
+ "GETMODS" { Get-Modifications $Args[1] $Args[2] $Args[3] }
+ "GETSOURCE" { Get-Source $Args[1] $Args[2] $Args[3] $Args[4] }
+ "SETLABEL" { Set-Label $Args[1] $Args[2] $Args[3] }
+ default { throw "Invalid opcode" }
+} \ No newline at end of file
diff --git a/tools/ccbootstrap.cmd b/tools/ccbootstrap.cmd
new file mode 100644
index 0000000..1eafad5
--- /dev/null
+++ b/tools/ccbootstrap.cmd
@@ -0,0 +1 @@
+@c:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -command "& %~dp0CruiseControlSourceControl.ps1 '%1' '%2' '%3' '%4' '%5' '%6' '%7' '%8' '%9'" \ No newline at end of file
diff --git a/tools/ccnet.config b/tools/ccnet.config
new file mode 100644
index 0000000..c23b7de
--- /dev/null
+++ b/tools/ccnet.config
@@ -0,0 +1,41 @@
+<cruisecontrol>
+ <project name="dotnetopenid-8">
+ <workingDirectory>c:\git\dotnetopenid</workingDirectory>
+ <sourcecontrol type="external">
+ <executable>c:\git\dotnetopenid\tools\ccbootstrap.cmd</executable>
+ <args>c:\git\dotnetopenid ci</args>
+ <autoGetSource>true</autoGetSource>
+ </sourcecontrol>
+ <triggers>
+ <intervalTrigger name="rolling" seconds="60" />
+ </triggers>
+ <prebuild>
+<!-- <exec>
+ <executable>C:\Program Files\git\bin\git.exe</executable>
+ <baseDirectory>c:\git\dotnetopenid</baseDirectory>
+ <buildArgs>pull</buildArgs>
+ </exec>-->
+ </prebuild>
+ <tasks>
+ <msbuild>
+ <executable>c:\windows\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
+ <workingDirectory>c:\git\dotnetopenid</workingDirectory>
+ <projectFile>c:\git\dotnetopenid\build.proj</projectFile>
+ <buildArgs>/noconsolelogger</buildArgs>
+ <targets>nightly</targets>
+ <timeout>900</timeout>
+ <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
+ </msbuild>
+ </tasks>
+ <publishers>
+ <merge>
+ <files>
+ <file>c:\git\dotnetopenid\bin\debug\test-results.xml</file>
+ </files>
+ </merge>
+ <xmllogger />
+ <statistics />
+ <!--<modificationHistory onlyLogWhenChangesFound="true" />-->
+ </publishers>
+ </project>
+</cruisecontrol> \ No newline at end of file