sync
[gitlive] / GitRepo.vala
index 6374b4f..2bfa2a1 100644 (file)
@@ -159,7 +159,7 @@ public class GitRepo : Object
         if (!FileUtils.test(this.gitdir , FileTest.IS_DIR)) {
             this.gitdir = path; // naked...
         }
-        this.cmds = new  Array<GitMonitorQueue> ();
+        this.cmds = new  Gee.ArrayList<GitMonitorQueue> ();
         
                var cache = GitRepo.singleton().cache;
         //Repo.superclass.constructor.call(this,cfg);
@@ -336,24 +336,46 @@ public class GitRepo : Object
     }
     
     
-   public void setActiveTicket(RooTicket ticket, string branchname)
+   public bool setActiveTicket(RooTicket ticket, string branchname)
     {
-       this.createBranchNamed(branchname);
+       if (!this.createBranchNamed(branchname)) {
+               return false;
+               }
        FileUtils.set_contents(this.gitdir + "/.gitlive-active-ticket" , ticket.id);
        this.activeTicket = ticket;
+       return true;
     }
     
-    public void createBranchNamed(string branchname)
+    public bool createBranchNamed(string branchname)
     {
-         if (this.branches.has_key(branchname)) {
-                string[] cmd = { "checkout", branchname  };
-                this.git(cmd);         
-       } else {
-                string[] cmd = { "checkout", "-b" , branchname  };
-                this.git(cmd);
-        }
+               
+               try {
+                    if (this.branches.has_key(branchname)) {
+                           string[] cmd = { "checkout", branchname  };
+                           this.git(cmd);         
+                   } else {
+                           string[] cmd = { "checkout", "-b" , branchname  };
+                           this.git(cmd);
+                   }
+                      var notification = new Notify.Notification(
+                       "Changed to branch %s".printf(branchname),
+                       "",
+                        "dialog-information"
+                       
+               );
+
+               notification.set_timeout(5);
+               notification.show();   
+       
+                   
+           } catch(Error e) {
+               GitMonitor.gitmonitor.pauseError(e.message);
+        return false;          
+           
+           }
         this.loadBranches(); // update branch list...
         GitMonitor.gitmonitor.runQueue(); // commit any outstanding...
+        return true;
     }
     
     
@@ -410,7 +432,7 @@ public class GitRepo : Object
      *
      * @argument {Array} files the files to add.
      */
-    public string remove  ( Array<GitMonitorQueue> files ) throws Error, SpawnError
+    public string remove  ( Gee.ArrayList<GitMonitorQueue> files ) throws Error, SpawnError
     {
         // this may fail if files do not exist..
         // should really find out if these are untracked files each..
@@ -418,8 +440,8 @@ public class GitRepo : Object
         // not sure if that is how git works.. but just be certian.
         var ret = "";
 
-        for (var i = 0; i < files.length;i++) {
-            var f = files.index(i).vname;
+        for (var i = 0; i < files.size;i++) {
+            var f = files.get(i).vname;
             try {
                 string[] cmd = { "rm",  "-f" ,  f  };
                 this.git( cmd );