-class RooTicket : Object
+public class RooTicket : Object
{
return _RooTicket;
}
public Gee.ArrayList<RooTicket> tickets; // only available for singletonn.
+ public string username = ""; // only available for singletonn.
+ public string password = ""; // only available for singletonn.
+
public string id; // not really important that they are numbers..
public string summary;
public string project_id_name;
+ public string summaryToBranchName()
+ {
+ // first 5 words of summary..
+ var regex = new Regex ("[^A-Za-z0-9 ]+");
+ var str = regex.replace(this.summary, this.summary.length,0, "");
+ string[] words = Regex.split_simple ("[ \t]+", str);
+ var ret = "";
+ for (var i =0; i< (words.length > 5 ? 5 : words.length); i++) {
+ ret += ret.length > 0 ? "_" : "";
+ ret += words[i];
+ }
+ return ret;
+ }
+ public string usernameLocal()
+ {
+ // git username is an email addres... - so this reutrns the local part..
+ //?? assumes that all members are under the same domain... normally the case......
+ return RooTicket.singleton().username.split("@")[0];
+
+ }
+
+
public void addTicket(Json.Object t)
{
var add = new RooTicket();
}
return null;
- }
+ }
+
public void loadTickets()
{
}
- public static void setAuth(Soup.Message message) {
-
- string str;
- var username = "";
- var password = "";
- GLib.FileUtils.get_contents(GLib.Environment.get_home_dir() + "/.netrc", out str);
- var lines = str.split("\n");
- for(var i=0; i< lines.length; i++) {
- // assumes one line per entry.. if not we are buggered...
- GLib.debug("got %s" , lines[i]);
-
- var bits = Regex.split_simple ("[ \t]+", lines[i].strip());
- if (bits.length < 6 || bits[0] != "machine" || bits[1] != "git.roojs.com") {
- continue;
- }
- GLib.debug("found password?");
- // we are gussing....
- username = bits[3];
- password = bits[5];
+ public static void setAuth(Soup.Message message)
+ {
+ var rs = RooTicket.singleton();
+ if (rs.username.length < 1) {
+ string str;
+ GLib.FileUtils.get_contents(GLib.Environment.get_home_dir() + "/.netrc", out str);
+ var lines = str.split("\n");
+ for(var i=0; i< lines.length; i++) {
+ // assumes one line per entry.. if not we are buggered...
+ GLib.debug("got %s" , lines[i]);
+ var bits = Regex.split_simple ("[ \t]+", lines[i].strip());
+ if (bits.length < 6 || bits[0] != "machine" || bits[1] != "git.roojs.com") {
+ continue;
+ }
+ GLib.debug("found password?");
+ // we are gussing....
+
+ RooTicket.singleton().username = bits[3];
+ RooTicket.singleton().password = bits[5];
+ }
}
- var authCode = Base64.encode ("%s:%s".printf(username, password).data);
+
+ var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
message.request_headers.append("Authorization", "Basic %s".printf(authCode));
}
+
+