Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed several issues:

- Commit message is now from most recent commit.
- Revision is shortened to first five characters.
- Added 'FindLast' to xml extensions to get the last node found by xpath instead of first.
  • Loading branch information...
commit f791db964c7bc7e6bf255986fd14941fc5837619 1 parent 7bdc9b5
@phil-b-higgins phil-b-higgins authored
View
8 Source/Hudson.Core/Extensions/FindExtension.cs
@@ -21,6 +21,14 @@ public static int FindInteger(this XmlNode xml, string xpath)
return int.TryParse(valueAsString, out value) ? value : 0;
}
+ public static string FindLast(this XmlNode xml, string xpath)
+ {
+ var selectedNodes = xml.SelectNodes(xpath);
+
+ return selectedNodes == null || selectedNodes.Count == 0 ?
+ String.Empty :
+ selectedNodes[selectedNodes.Count - 1].InnerText;
+ }
/// <summary>
/// Finds the given node and returns it as a <see cref="Uri"/> object.
View
6 Source/Hudson.Core/Mappers/BuildMapper.cs
@@ -31,7 +31,7 @@ public Build Map(XmlDocument xml)
Number = xml.FindInteger("//number"),
Success = xml.Find("//result") == "SUCCESS",
Url = new Uri(xml.Find("//url")),
- User = xml.Find("//author//fullName")
+ User = xml.FindLast("//author//fullName")
};
// Hudson Properties
@@ -48,8 +48,8 @@ public Build Map(XmlDocument xml)
build.Created = JavaTimeStampToDateTime(seconds);
// GIT Properties
- build.Revision = xml.Find("//lastBuiltRevision//SHA1");
- build.Comments = xml.Find("//msg");
+ build.Revision = xml.Find("//lastBuiltRevision//SHA1").Substring(0, 5);
+ build.Comments = xml.FindLast("//msg");
}
return build;
View
2  Source/Hudson.Test/Mappers/BuildMapperTest.cs
@@ -31,7 +31,7 @@ public void TestMapBuild()
Assert.AreEqual(false, build.KeepLog);
Assert.AreEqual("Fixed stuff.", build.Comments);
Assert.AreEqual(1124, build.Number);
- Assert.AreEqual("fa8825becade7adf64212e2395460d290e201d08", build.Revision);
+ Assert.AreEqual("fa882", build.Revision);
Assert.AreEqual(true, build.Success);
Assert.AreEqual("http://www.example.com/job/first-job/92/", build.Url.ToString());
Assert.AreEqual(DateTime.Parse("2012-02-20 17:09:39"), build.Created);
View
14 Source/Hudson.Test/Xml/BuildResponse.xml
@@ -49,6 +49,20 @@
<changeSet>
<item>
<author>
+ <absoluteUrl>http://www.example.com:3333/user/test.other</absoluteUrl>
+ <fullName>test.other</fullName>
+ </author>
+ <comment>Ignore this.</comment>
+ <date>2012-02-20 17:00:00 +0000</date>
+ <id>d7da709252cbeff92c7992a4ca89908b6f68bbe1</id>
+ <msg>Ignore this.</msg>
+ <path>
+ <editType>edit</editType>
+ <file>Source/File.cs</file>
+ </path>
+ </item>
+ <item>
+ <author>
<absoluteUrl>http://www.example.com:3333/user/test.user</absoluteUrl>
<fullName>test.user</fullName>
</author>
Please sign in to comment.
Something went wrong with that request. Please try again.