• R/O
  • SSH
  • HTTPS

vssjscript: Commit


Commit MetaInfo

Revision6 (tree)
Zeit2011-12-29 10:23:39
Autortejima

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- trunk/trac.js (nonexistent)
+++ trunk/trac.js (revision 6)
@@ -0,0 +1,91 @@
1+var config = {
2+ url: "http://localhost/trac/SampleProject/login/xmlrpc",
3+ username: "admin",
4+ password: "admin"
5+};
6+var xhr = new ActiveXObject("Msxml2.ServerXMLHTTP");
7+var tickets = [];
8+var futures = {};
9+var timeoutid = 0;
10+function tracXmlRpc (xml) {
11+ xhr.open("POST", config.url, false, config.username, config.password);
12+ xhr.setRequestHeader("content-type", "application/xml");
13+ xhr.send(xml.xml);
14+ var result = xhr.responseXML
15+ if (result.getElementsByTagName("fault").length != 0) throw new Error(result.text);
16+ return result;
17+}
18+function ticketQuery (id) {
19+ var xml = new ActiveXObject("Msxml2.DOMDocument");
20+ xml.appendChild(xml.createProcessingInstruction("xml", "version='1.0'"));
21+ var methodCall = xml.appendChild(xml.createElement("methodCall"));
22+ methodCall.appendChild(xml.createElement("methodName")).text = "ticket.query";
23+ var params = methodCall.appendChild(xml.createElement("params"));
24+ params.appendChild(xml.createElement("param")).appendChild(xml.createElement("string")).text = "id=" + id;
25+ return tracXmlRpc(xml);
26+}
27+function ticketUpdate (id, comments) {
28+ var xml = new ActiveXObject("Msxml2.DOMDocument");
29+ xml.appendChild(xml.createProcessingInstruction("xml", "version='1.0'"));
30+ var methodCall = xml.appendChild(xml.createElement("methodCall"));
31+ methodCall.appendChild(xml.createElement("methodName")).text = "ticket.update";
32+ var params = methodCall.appendChild(xml.createElement("params"));
33+ params.appendChild(xml.createElement("param")).appendChild(xml.createElement("int")).text = id;
34+ params.appendChild(xml.createElement("param")).appendChild(xml.createElement("string")).text = comments;
35+ return tracXmlRpc(xml);
36+}
37+function parseComments (comments) {
38+ var see = comments.match(/\[see\s*#(\d+)\s*\]/mg);
39+ var result = [];
40+ if (see != null) for (var i = 0, n = see.length; i < n; ++i) result.push(see[i].match(/\d+/));
41+ return result;
42+}
43+function ensureTicketExists (id) {
44+ for (var i = 0, n = tickets.length; i < n; ++i) if (tickets[i] == id) return false;
45+ var res = ticketQuery(id);
46+ if (res.getElementsByTagName("int").length == 0) throw new Error("#" + id + " not found.");
47+ tickets.push(id);
48+ return true;
49+}
50+function BeforeCheckin(d, u, r, v, l, c) {
51+ var id = parseComments(c);
52+ if (id.length == 0) throw new Error("チケット番号を指定してください。例: [see #42].");
53+ for (var i = 0, n = id.length; i < n; ++i) ensureTicketExists(id[i]);
54+}
55+function AfterCheckin(d, u, r, v, l, c) {
56+ alert("c/i: " + r + ";" + v);
57+ var a = "c/i: " + r.replace(/\s+$/g, "") + ";" + ("" + v).replace(/\s+$/g, "") + " (" + u.replace(/\s+$/g, "") + ")\r\n";
58+ if (futures[c] == undefined) {
59+ futures[c] = a;
60+ if (timeoutid != 0) clearTimeout(timeoutid);
61+ timeoutid = setTimeout("ticketUpdateFuture()", 3000);
62+ } else {
63+ futures[c] += a;
64+ }
65+}
66+function ticketUpdateFuture() {
67+ if (timeoutid != 0) clearTimeout(timeoutid);
68+ timeoutid = 0;
69+ for (c in futures) {
70+ if (c == undefined) continue;
71+ var id = parseComments(c);
72+ for (var i = 0, n = id.length; i < n; ++i) {
73+ ticketUpdate(id[i], futures[c] + c);
74+ alert("#" + id[i] + " updated");
75+ }
76+ delete futures[c];
77+ break;
78+ }
79+}
80+// function BeforeAdd(SrcSafeIni, UserName, Spec, VersionNumber, Local, Comment) { alert("BeforeAdd"); }
81+function AfterAdd(SrcSafeIni, UserName, Spec, VersionNumber, Local, Comment) { alert("add: " + Spec + ";" + VersionNumber); }
82+// function BeforeCheckout(SrcSafeIni, UserName, Spec, VersionNumber, Local, Comment) { alert("BeforeCheckout"); }
83+function AfterCheckout(SrcSafeIni, UserName, Spec, VersionNumber, Local, Comment) { alert("c/o: " + Spec + ";" + VersionNumber); }
84+// function BeforeCheckin(SrcSafeIni, UserName, Spec, VersionNumber, Local, Comment) { alert("BeforeCheckin"); }
85+// function AfterCheckin(SrcSafeIni, UserName, Spec, VersionNumber, Local, Comment) { alert("C/i: " + Spec + ";" + VersionNumber); }
86+// function BeforeUndoCheckout(SrcSafeIni, UserName, Spec, VersionNumber, Local) { alert("BeforeUndoCheckout"); }
87+function AfterUndoCheckout(SrcSafeIni, UserName, Spec, VersionNumber, Local) { alert("undo: " + Spec + ";" + VersionNumber); }
88+// function BeforeRename(SrcSafeIni, UserName, Spec, VersionNumber, NewName) { alert("BeforeRename"); }
89+function AfterRename(SrcSafeIni, UserName, Spec, VersionNumber, OldName) { alert("rename: " + Spec + ";" + VersionNumber + "←" + OldName); }
90+// function BeforeBranch(SrcSafeIni, UserName, Spec, VersionNumber, Comment) { alert("BeforeBranch"); }
91+function AfterBranch(SrcSafeIni, UserName, Spec, VersionNumber, Comment) { alert("branch: " + Spec + ";" + VersionNumber); }
Added: svn:needs-lock
## -0,0 +1 ##
+*
\ No newline at end of property
Show on old repository browser