Partial Fix #5560 - Gitlive - branching wip
authorAlan Knowles <alan@roojs.com>
Mon, 12 Nov 2018 06:58:03 +0000 (14:58 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 12 Nov 2018 06:58:03 +0000 (14:58 +0800)
Clones.bjs
Clones.vala
GitRepo.vala
MergeBranch.bjs
MergeBranch.vala
NewBranch.bjs
NewBranch.vala
RooTicket.vala

index a1630a7..b7c91c2 100644 (file)
@@ -13,8 +13,8 @@
     "response" : "(self, response_id) =>  { \n \n        this.el.hide();\n  \n}"
    },
    "default_width" : 800,
-   "$ deletable" : true,
    "| void show" : "()    {\n\n    \n    this.el.set_deletable(false);\n    this.el.set_gravity(Gdk.Gravity.NORTH);\n    this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);\n    this.el.show_all();\n    _this.reposStore.load();\n    // load clones..\n//     this.get('/reposStore').load();\n    \n    //this.get('/ok_button').el.set_sensitive(false);\n    \n    // block until we return.\n//    var run_ret = this.el.run();\n//    if (run_ret < 1 ) {\n//        return  \"DONE\";\n//    }\n//    print(\"RUN RETURN : \" + run_ret);\n//    return \"DONE\";\n    //print(JSON.stringify(this.get('bug').getValue()));\n   // return this.get('bug').getValue();\n    //this.success = c.success;\n}\n",
+   "$ deletable" : true,
    "title" : "Manage Clones",
    "xtype" : "Dialog",
    "default_height" : 500,
@@ -39,8 +39,8 @@
           "clicked" : "() => {\n\n/*    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Remotes =     imports.Remotes.Remotes;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Remotes.repo = repo;\n    Remotes.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Remotes.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n  */   \n    \n     \n\n       \n    \n    \n}"
          },
          "label" : "Remotes / Clones",
-         "xtype" : "Button",
          "* pack" : "add",
+         "xtype" : "Button",
          "$ xns" : "Gtk"
         },
         {
@@ -48,8 +48,8 @@
           "clicked" : "() => {\n// \n\n\t//NewBranch.singleton().show();\n\n/*\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Branches =     imports.Branches.Branches;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Branches.repo = repo;\n    Branches.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Branches.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n     \n    \n    \n    \n\n       \n */   \n    \n}"
          },
          "label" : "Branches",
-         "xtype" : "Button",
          "* pack" : "add",
+         "xtype" : "Button",
          "$ xns" : "Gtk"
         },
         {
@@ -57,8 +57,8 @@
           "clicked" : "() =>  {\n/*\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Merger =     imports.Merger.Merger;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Merger.repo = repo;\n    Merger.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Merger.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n    \n    \n\n     \n    \n\n */      \n    \n    \n}"
          },
          "label" : "Merge",
-         "xtype" : "Button",
          "* pack" : "add",
+         "xtype" : "Button",
          "$ xns" : "Gtk"
         },
         {
@@ -66,8 +66,8 @@
           "clicked" : "() => {\n    \n    \n \n       \n    \n    \n}"
          },
          "label" : "Switch Branch",
-         "xtype" : "Button",
          "* pack" : "add",
+         "xtype" : "Button",
          "$ xns" : "Gtk"
         },
         {
           "clicked" : "() => {\n    \n    \n \n       \n    \n    \n}"
          },
          "label" : "Pull",
-         "xtype" : "Button",
          "* pack" : "add",
+         "xtype" : "Button",
          "$ xns" : "Gtk"
         }
        ]
       },
       {
        "* init" : "  {\n  \n   this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n",
-       "bool expand" : true,
        "bool hexpand" : true,
+       "bool expand" : true,
        "xtype" : "ScrolledWindow",
        "* pack" : "pack_end,true,true,0",
        "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
          "$ xns" : "Gtk",
          "items" : [
           {
-           "int n_columns" : 8,
+           "int n_columns" : 10,
            "id" : "reposStore",
-           "columns" : "     typeof(string),  // 0 repo\n     typeof(string),  // 1 current branch\n     typeof(string),  // 2 all branch\n     typeof(string),  // 3 updated\n     typeof(bool),   // 4 auto commit\n     typeof(bool),   // 5 auto push\n     typeof(string),   // 7 repopath\n      typeof(string)   // 8 color highlighting?\n      ",
+           "columns" : "     typeof(string),  // 0 repo\n     typeof(string),  // 1 current branch\n     typeof(string),  // 2 all branch\n     typeof(string),  // 3 updated\n     typeof(bool),   // 4 auto commit\n     typeof(bool),   // 5 auto push\n     typeof(string),   // 6 repopath\n      typeof(string),   // 7 color highlighting?\n       typeof(bool),   // 8 auto branch,\n      typeof(string)   // 9 active Ticket\n      ",
            "$ pathToRepo" : "function(path) {\n\n    var tr= this.repos;\n\n    \n    for(var i =0 ; i < tr.length; i++) {\n        if (tr[i].repopath == path) {\n            return tr[i];\n        }\n    } \n    return false; \n}\n",
            "xtype" : "ListStore",
            "* pack" : "set_model",
-           "| void load" : "()\n{\n    //this.insert(citer,iter,0);\n    print(\"getting list\");\n    var tr = GitRepo.list();\n    \n    this.el.clear();\n    \n    // fixme .. sort by last updated ...\n    \n    \n    for(var i =0 ; i < tr.length; i++) {\n\t    var repo = tr.index(i);\n\t    repo.loadBranches();\n\t    \n\t    Gtk.TreeIter iter;\n\t    this.el.append(out iter);\n     \n        \n        //print(JSON.stringify(ret,null,4));\n         //tr[i].getBranches();\n         //tr[i].getStatus();\n         //var hi;\n         //try {\n             //tr[i].debug=1;\n         //     hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );\n//             print(JSON.stringify(hi,null,4));\n        // } catch(e) { print(e);}\n          \n        this.el.set_value(iter, 0,   repo.name );\n        this.el.set_value( iter, 1, repo.currentBranch.name   );\n        this.el.set_value( iter, 2,  repo.branchesToString()   );\n//        this.el.set_value(ret.iter, 2, '' + repo.branches.map(\n//                        function(e) { return e.name; \n//                    }).join(', ') \n //        );\n//        this.el.set_value(iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        \n        this.el.set_value(iter, 4, repo.is_autocommit() );                \n        this.el.set_value(iter, 5, repo.is_autopush() );                        \n        this.el.set_value(iter, 6,  repo.gitdir );  \n        // highlight color.\n        var cb = repo.currentBranch;\n        //print(JSON.stringify(cb,null,4));\n        var col = \"#ffffff\";\n        /*\n        if (cb.lastrev != cb.remoterev) {\n            col =  '#ff0000';\n        }\n        if (tr[i].hasLocalChanges) {\n            col =  '#0000ff';\n        }\n        if  ((cb.lastrev != cb.remoterev) && (tr[i].hasLocalChanges)) {\n            col =  '#ff00ff';\n        }\n        */\n        this.el.set_value(iter, 7, col  );      \n        \n    }     \n    this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);\n} ",
+           "| void load" : "()\n{\n    //this.insert(citer,iter,0);\n    print(\"getting list\");\n    var tr = GitRepo.list();\n    \n    this.el.clear();\n    \n    // fixme .. sort by last updated ...\n    \n    \n    for(var i =0 ; i < tr.length; i++) {\n\t    var repo = tr.index(i);\n\t    repo.loadBranches();\n\t    \n\t    Gtk.TreeIter iter;\n\t    this.el.append(out iter);\n     \n        \n        //print(JSON.stringify(ret,null,4));\n         //tr[i].getBranches();\n         //tr[i].getStatus();\n         //var hi;\n         //try {\n             //tr[i].debug=1;\n         //     hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );\n//             print(JSON.stringify(hi,null,4));\n        // } catch(e) { print(e);}\n          \n        this.el.set_value(iter, 0,   repo.name );\n        this.el.set_value( iter, 1, repo.currentBranch.name   );\n        this.el.set_value( iter, 2,  repo.branchesToString()   );\n//        this.el.set_value(ret.iter, 2, '' + repo.branches.map(\n//                        function(e) { return e.name; \n//                    }).join(', ') \n //        );\n//        this.el.set_value(iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        \n        this.el.set_value(iter, 4, repo.is_autocommit() );                \n        this.el.set_value(iter, 5, repo.is_autopush() );                        \n        this.el.set_value(iter, 6,  repo.git_working_dir );  \n        // highlight color.\n        var cb = repo.currentBranch;\n        //print(JSON.stringify(cb,null,4));\n        var col = \"#ffffff\";\n        /*\n        if (cb.lastrev != cb.remoterev) {\n            col =  '#ff0000';\n        }\n        if (tr[i].hasLocalChanges) {\n            col =  '#0000ff';\n        }\n        if  ((cb.lastrev != cb.remoterev) && (tr[i].hasLocalChanges)) {\n            col =  '#ff00ff';\n        }\n        */\n        this.el.set_value(iter, 7, col  );      \n        var ticket = repo.activeTicket;\n        \n        this.el.set_value(iter, 8, repo.is_auto_branch()  );      \n        this.el.set_value(iter, 9, ticket == null ? \"\" : ticket.id  );      \n        \n        \n    }     \n    this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);\n} ",
            "$ xns" : "Gtk"
           },
           {
            "items" : [
             {
              "listeners" : {
-              "toggled" : "  (self, path)  => {\n/*    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,4).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,4, !value);\n    \n     var path =  store.el.get_value(ret.iter, 6).value.get_string();\n     var repo = imports.Scm.Repo.Repo.get(path);\n     repo.autocommit(!value);\n  */   \n    \n    \n}"
+              "toggled" : "  (self, path)  => {\n  \n  \tGtk.TreeIter iter;\n  \t_this.reposStore.el.get_iter_from_string(out iter, path);\n  \t\n  \tGLib.Value val;\n  \tGLib.Value rval;\n  \t_this.reposStore.el.get_value(iter, 4, out val);\n  \t_this.reposStore.el.get_value(iter, 6, out rval);\n  \t\n  \tvar repopath = (string)rval;\n  \tvar bval = (bool)val;\n  \t_this.reposStore.el.set_value(iter, 4, !bval);\n  \tGLib.debug(\"got repopath? %s\", repopath);\n  \t\n  \tvar repo = GitRepo.get(repopath);\n  \trepo.set_autocommit(!bval);\n  \t\n  \t\n  \t\n  \n}"
              },
              "id" : "cr_autocommit",
-             "xtype" : "CellRendererToggle",
              "* pack" : "pack_start,false",
+             "xtype" : "CellRendererToggle",
              "$ xns" : "Gtk",
              "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE"
             }
            "items" : [
             {
              "listeners" : {
-              "toggled" : "  (self, path)  => {\n/*    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,5).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,5, !value);\n      var path =  store.el.get_value(ret.iter, 6).value.get_string();\n     var repo = imports.Scm.Repo.Repo.get(path);\n     repo.autopush(!value);\n    */\n}"
+              "toggled" : "  (self, path)  => {\n  \n  \tGtk.TreeIter iter;\n  \t_this.reposStore.el.get_iter_from_string(out iter, path);\n  \t\n  \tGLib.Value val;\n  \tGLib.Value rval;\n  \t_this.reposStore.el.get_value(iter, 5, out val);\n  \t_this.reposStore.el.get_value(iter, 6, out rval);\n  \t\n  \tvar repopath = (string)rval;\n  \tvar bval = (bool)val;\n  \t_this.reposStore.el.set_value(iter, 5, !bval);\n  \tvar repo = GitRepo.get(repopath);\n  \trepo.set_autopush(!bval);\n  \t\n  \t\n  \t\n  \n}"
              },
              "id" : "cr_autopush",
+             "* pack" : "pack_start,false",
+             "xtype" : "CellRendererToggle",
+             "$ xns" : "Gtk",
+             "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE"
+            }
+           ]
+          },
+          {
+           "id" : "tv_autobranch",
+           "* init" : " \n    this.el.add_attribute(_this.cr_autobranch.el , \"active\", 8 );\n//      this.items[0].el.set_activatable(true);\n\n",
+           "* pack" : "append_column",
+           "title" : "Auto Branch",
+           "xtype" : "TreeViewColumn",
+           "min_width" : 50,
+           "$ xns" : "Gtk",
+           "items" : [
+            {
+             "listeners" : {
+              "toggled" : "  (self, path)  => {\n  \n  \tGtk.TreeIter iter;\n  \t_this.reposStore.el.get_iter_from_string(out iter, path);\n  \t\n  \tGLib.Value val;\n  \tGLib.Value rval;\n  \t_this.reposStore.el.get_value(iter, 8, out val);\n  \t_this.reposStore.el.get_value(iter, 6, out rval);\n  \t\n  \tvar repopath = (string)rval;\n  \tvar bval = (bool)val;\n  \t_this.reposStore.el.set_value(iter, 8, !bval);\n  \tvar repo = GitRepo.get(repopath);\n  \trepo.set_auto_branch(!bval);\n  \t\n  \t\n  \t\n  \n}"
+             },
+             "id" : "cr_autobranch",
              "xtype" : "CellRendererToggle",
              "* pack" : "pack_start,false",
              "$ xns" : "Gtk",
           },
           {
            "id" : "tv_repo",
-           "Gtk.SortType sort_order" : "Gtk.SortType.ASCENDING",
            "* init" : "\n    this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n",
+           "Gtk.SortType sort_order" : "Gtk.SortType.ASCENDING",
            "title" : "Repo",
            "* pack" : "append_column",
            "xtype" : "TreeViewColumn",
            "items" : [
             {
              "id" : "cr_repo",
+             "* pack" : "pack_start,false",
+             "xtype" : "CellRendererText",
+             "$ xns" : "Gtk"
+            }
+           ]
+          },
+          {
+           "id" : "tv_active_ticket",
+           "* init" : "this.el.add_attribute(_this.cr_active_ticket.el , \"markup\", 9 ); ",
+           "* pack" : "append_column",
+           "title" : "Active Ticket",
+           "xtype" : "TreeViewColumn",
+           "min_width" : 50,
+           "$ xns" : "Gtk",
+           "items" : [
+            {
+             "id" : "cr_active_ticket",
              "xtype" : "CellRendererText",
              "* pack" : "pack_start,false",
              "$ xns" : "Gtk"
            "items" : [
             {
              "id" : "cr_current_branch",
-             "xtype" : "CellRendererText",
              "* pack" : "pack_start,false",
+             "xtype" : "CellRendererText",
              "$ xns" : "Gtk"
             }
            ]
            "items" : [
             {
              "id" : "cr_last_updated",
-             "xtype" : "CellRendererText",
              "* pack" : "pack_start,false",
+             "xtype" : "CellRendererText",
              "$ xns" : "Gtk"
             }
            ]
            "items" : [
             {
              "id" : "cr_all_branches",
-             "xtype" : "CellRendererText",
              "* pack" : "pack_start,false",
+             "xtype" : "CellRendererText",
              "$ xns" : "Gtk"
             }
            ]
index 3a91a66..d5e2918 100644 (file)
@@ -18,8 +18,12 @@ public class Clones : Object
     public Xcls_cr_autocommit cr_autocommit;
     public Xcls_tv_autopush tv_autopush;
     public Xcls_cr_autopush cr_autopush;
+    public Xcls_tv_autobranch tv_autobranch;
+    public Xcls_cr_autobranch cr_autobranch;
     public Xcls_tv_repo tv_repo;
     public Xcls_cr_repo cr_repo;
+    public Xcls_tv_active_ticket tv_active_ticket;
+    public Xcls_cr_active_ticket cr_active_ticket;
     public Xcls_tv_current_branch tv_current_branch;
     public Xcls_cr_current_branch cr_current_branch;
     public Xcls_tv_last_updated tv_last_updated;
@@ -492,18 +496,24 @@ public class Clones : Object
             var child_2 = new Xcls_tv_autopush( _this );
             child_2.ref();
             this.el.append_column (  child_2.el  );
-            var child_3 = new Xcls_tv_repo( _this );
+            var child_3 = new Xcls_tv_autobranch( _this );
             child_3.ref();
             this.el.append_column (  child_3.el  );
-            var child_4 = new Xcls_tv_current_branch( _this );
+            var child_4 = new Xcls_tv_repo( _this );
             child_4.ref();
             this.el.append_column (  child_4.el  );
-            var child_5 = new Xcls_tv_last_updated( _this );
+            var child_5 = new Xcls_tv_active_ticket( _this );
             child_5.ref();
             this.el.append_column (  child_5.el  );
-            var child_6 = new Xcls_tv_all_branches( _this );
+            var child_6 = new Xcls_tv_current_branch( _this );
             child_6.ref();
             this.el.append_column (  child_6.el  );
+            var child_7 = new Xcls_tv_last_updated( _this );
+            child_7.ref();
+            this.el.append_column (  child_7.el  );
+            var child_8 = new Xcls_tv_all_branches( _this );
+            child_8.ref();
+            this.el.append_column (  child_8.el  );
 
             // init method
 
@@ -564,14 +574,16 @@ public class Clones : Object
         {
             _this = _owner;
             _this.reposStore = this;
-            this.el = new Gtk.ListStore( 8,      typeof(string),  // 0 repo
+            this.el = new Gtk.ListStore( 10,      typeof(string),  // 0 repo
      typeof(string),  // 1 current branch
      typeof(string),  // 2 all branch
      typeof(string),  // 3 updated
      typeof(bool),   // 4 auto commit
      typeof(bool),   // 5 auto push
-     typeof(string),   // 7 repopath
-      typeof(string)   // 8 color highlighting?
+     typeof(string),   // 6 repopath
+      typeof(string),   // 7 color highlighting?
+       typeof(bool),   // 8 auto branch,
+      typeof(string)   // 9 active Ticket
        );
 
             // my vars (dec)
@@ -619,7 +631,7 @@ public class Clones : Object
         //        this.el.set_value(iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        
                 this.el.set_value(iter, 4, repo.is_autocommit() );                
                 this.el.set_value(iter, 5, repo.is_autopush() );                        
-                this.el.set_value(iter, 6,  repo.gitdir );  
+                this.el.set_value(iter, 6,  repo.git_working_dir );  
                 // highlight color.
                 var cb = repo.currentBranch;
                 //print(JSON.stringify(cb,null,4));
@@ -636,6 +648,11 @@ public class Clones : Object
                 }
                 */
                 this.el.set_value(iter, 7, col  );      
+                var ticket = repo.activeTicket;
+                
+                this.el.set_value(iter, 8, repo.is_auto_branch()  );      
+                this.el.set_value(iter, 9, ticket == null ? "" : ticket.id  );      
+                
                 
             }     
             this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);
@@ -696,21 +713,26 @@ public class Clones : Object
 
             //listeners
             this.el.toggled.connect( (self, path)  => {
-            /*    var ret ={} ;
-                var store = this.get('/reposStore');
-                store.el.get_iter_from_string(ret, path);
-                                                                             
-                var value =   store.el.get_value(ret.iter,4).value.get_boolean();
-                                                                             
-                //print(JSON.stringify(value));
-                store.el.set_value(ret.iter,4, !value);
-                
-                 var path =  store.el.get_value(ret.iter, 6).value.get_string();
-                 var repo = imports.Scm.Repo.Repo.get(path);
-                 repo.autocommit(!value);
-              */   
-                
-                
+              
+               Gtk.TreeIter iter;
+               _this.reposStore.el.get_iter_from_string(out iter, path);
+               
+               GLib.Value val;
+               GLib.Value rval;
+               _this.reposStore.el.get_value(iter, 4, out val);
+               _this.reposStore.el.get_value(iter, 6, out rval);
+               
+               var repopath = (string)rval;
+               var bval = (bool)val;
+               _this.reposStore.el.set_value(iter, 4, !bval);
+               GLib.debug("got repopath? %s", repopath);
+               
+               var repo = GitRepo.get(repopath);
+               repo.set_autocommit(!bval);
+               
+               
+               
+              
             });
         }
 
@@ -772,18 +794,103 @@ public class Clones : Object
 
             //listeners
             this.el.toggled.connect( (self, path)  => {
-            /*    var ret ={} ;
-                var store = this.get('/reposStore');
-                store.el.get_iter_from_string(ret, path);
-                                                                             
-                var value =   store.el.get_value(ret.iter,5).value.get_boolean();
-                                                                             
-                //print(JSON.stringify(value));
-                store.el.set_value(ret.iter,5, !value);
-                  var path =  store.el.get_value(ret.iter, 6).value.get_string();
-                 var repo = imports.Scm.Repo.Repo.get(path);
-                 repo.autopush(!value);
-                */
+              
+               Gtk.TreeIter iter;
+               _this.reposStore.el.get_iter_from_string(out iter, path);
+               
+               GLib.Value val;
+               GLib.Value rval;
+               _this.reposStore.el.get_value(iter, 5, out val);
+               _this.reposStore.el.get_value(iter, 6, out rval);
+               
+               var repopath = (string)rval;
+               var bval = (bool)val;
+               _this.reposStore.el.set_value(iter, 5, !bval);
+               var repo = GitRepo.get(repopath);
+               repo.set_autopush(!bval);
+               
+               
+               
+              
+            });
+        }
+
+        // user defined functions
+    }
+
+
+    public class Xcls_tv_autobranch : Object
+    {
+        public Gtk.TreeViewColumn el;
+        private Clones  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_tv_autobranch(Clones _owner )
+        {
+            _this = _owner;
+            _this.tv_autobranch = this;
+            this.el = new Gtk.TreeViewColumn();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.title = "Auto Branch";
+            this.el.min_width = 50;
+            var child_0 = new Xcls_cr_autobranch( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , false );
+
+            // init method
+
+            this.el.add_attribute(_this.cr_autobranch.el , "active", 8 );
+            //      this.items[0].el.set_activatable(true);
+        }
+
+        // user defined functions
+    }
+    public class Xcls_cr_autobranch : Object
+    {
+        public Gtk.CellRendererToggle el;
+        private Clones  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_cr_autobranch(Clones _owner )
+        {
+            _this = _owner;
+            _this.cr_autobranch = this;
+            this.el = new Gtk.CellRendererToggle();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
+
+            //listeners
+            this.el.toggled.connect( (self, path)  => {
+              
+               Gtk.TreeIter iter;
+               _this.reposStore.el.get_iter_from_string(out iter, path);
+               
+               GLib.Value val;
+               GLib.Value rval;
+               _this.reposStore.el.get_value(iter, 8, out val);
+               _this.reposStore.el.get_value(iter, 6, out rval);
+               
+               var repopath = (string)rval;
+               var bval = (bool)val;
+               _this.reposStore.el.set_value(iter, 8, !bval);
+               var repo = GitRepo.get(repopath);
+               repo.set_auto_branch(!bval);
+               
+               
+               
+              
             });
         }
 
@@ -849,6 +956,61 @@ public class Clones : Object
     }
 
 
+    public class Xcls_tv_active_ticket : Object
+    {
+        public Gtk.TreeViewColumn el;
+        private Clones  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_tv_active_ticket(Clones _owner )
+        {
+            _this = _owner;
+            _this.tv_active_ticket = this;
+            this.el = new Gtk.TreeViewColumn();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.title = "Active Ticket";
+            this.el.min_width = 50;
+            var child_0 = new Xcls_cr_active_ticket( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , false );
+
+            // init method
+
+            this.el.add_attribute(_this.cr_active_ticket.el , "markup", 9 );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_cr_active_ticket : Object
+    {
+        public Gtk.CellRendererText el;
+        private Clones  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_cr_active_ticket(Clones _owner )
+        {
+            _this = _owner;
+            _this.cr_active_ticket = this;
+            this.el = new Gtk.CellRendererText();
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+
     public class Xcls_tv_current_branch : Object
     {
         public Gtk.TreeViewColumn el;
index ec10a01..cf962d6 100644 (file)
@@ -180,15 +180,67 @@ public class GitRepo : Object
     {
        return !FileUtils.test(this.gitdir + "/.gitlive-disable-autocommit" , FileTest.EXISTS);
     }
+    public void set_autocommit(bool val)
+    {
+
+               var cur = this.is_autocommit();
+               GLib.debug("SET auto commit : %s <= %s", val ? "ON" : "OFF",  cur  ? "ON" : "OFF");
+               if (cur == val) {
+                       return; // no change..
+               }
+               if (!val) {
+                       FileUtils.set_contents(this.gitdir + "/.gitlive-disable-autocommit" , "x");
+               } else {
+                       // it exists...
+                       FileUtils.remove(this.gitdir + "/.gitlive-disable-autocommit" ); 
+               }
+    
+    }
     
     public bool is_auto_branch ()
     {
        return FileUtils.test(this.gitdir + "/.gitlive-enable-auto-branch" , FileTest.EXISTS);
     }
+    
+    public void set_auto_branch(bool val)
+    {
+
+               var cur = this.is_auto_branch();
+               GLib.debug("SET auto branch : %s <= %s", val ? "ON" : "OFF",  cur  ? "ON" : "OFF");
+               
+               if (cur == val) {
+                       return; // no change..
+               }
+               if (val) {
+                       FileUtils.set_contents(this.gitdir + "/.gitlive-enable-auto-branch" , "x");
+               } else {
+                       // it exists...
+                       FileUtils.remove(this.gitdir + "/.gitlive-enable-auto-branch" ); 
+               }
+    
+    }
     public bool is_autopush ()
     {
        return !FileUtils.test(this.gitdir + "/.gitlive-disable-autopush" , FileTest.EXISTS);
     }
+    public void set_autopush(bool val)
+    {
+
+               var cur = this.is_autopush();
+               GLib.debug("SET auto push : %s <= %s", val ? "ON" : "OFF",  cur  ? "ON" : "OFF");
+               if (cur == val) {
+                       return; // no change..
+               }
+               if (!val) {
+                       FileUtils.set_contents(this.gitdir + "/.gitlive-disable-autopush" , "");
+               } else {
+                       // it exists...
+                       FileUtils.remove(this.gitdir + "/.gitlive-disable-autopush" ); 
+               }
+    
+    }
+    
+    
     
     Gee.HashMap<string,GitBranch> branches;
     
@@ -426,10 +478,10 @@ public class GitRepo : Object
                                           
                                        string[] cmd = { "checkout", "-b" , branchname  };
                                        this.git(cmd);
-                       this.push();    
-                       cmd = { "branch", "--set-upstream-to=origin/"+branchname , branchname  };
+
+                       cmd = { "push", "-u" , "origin" ,"HEAD"  };
                                        this.git(cmd);
-                       
+                     
                                        } catch(Error ee) {
                                                GitMonitor.gitmonitor.pauseError(ee.message);
                                                return false;           
index 2fa6f41..37ea9e4 100644 (file)
@@ -31,8 +31,8 @@
      "items" : [
       {
        "bool homogeneous" : false,
-       "xtype" : "Table",
        "* pack" : "pack_start,false,false,0",
+       "xtype" : "Table",
        "uint column_spacing" : 2,
        "n_columns" : 2,
        "$ xns" : "Gtk",
          "items" : [
           {
            "id" : "actioncellrenderer",
-           "xtype" : "CellRendererText",
            "* pack" : "pack_start,true",
+           "xtype" : "CellRendererText",
            "$ xns" : "Gtk"
           },
           {
            "id" : "actionmodel",
-           "xtype" : "ListStore",
            "* pack" : "set_model",
+           "xtype" : "ListStore",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
            "$ xns" : "Gtk",
          "items" : [
           {
            "id" : "dbcellrenderer",
-           "* pack" : "pack_start,true",
            "xtype" : "CellRendererText",
+           "* pack" : "pack_start,true",
            "$ xns" : "Gtk"
           },
           {
            "id" : "dbmodel",
-           "* pack" : "set_model",
            "xtype" : "ListStore",
-           "| void loadTickets" : "  () {\n\n    RooTicket.singleton().loadTickets();\n    \n    _this.ticketsel.loading = true;\n\n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n    el.append(out iter);\n\n    \n    el.set_value(iter, 0, \"\");\n    el.set_value(iter, 1, \"-- select a ticket --\");\n    \n    _this.ticketsel.el.set_active_iter(iter);\n    var tickets = RooTicket.singleton().tickets;\n    foreach(var ticket in tickets) {\n    \n        el.append(out iter);\n\n        el.set_value(iter, 0, ticket.id);\n        el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n\t\tif (_this.ticket.id == ticket.id) {\n\t\t    _this.ticketsel.el.set_active_iter(iter);\n\t    }\n        \n    }\n    \n    _this.ticketsel.loading = false;\n     //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n",
+           "* pack" : "set_model",
+           "| void loadTickets" : "  () {\n\n    RooTicket.singleton().loadTickets();\n    \n    _this.ticketsel.loading = true;\n\n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n    el.append(out iter);\n    el.set_value(iter, 0, \"\");\n    el.set_value(iter, 1, \"-- select a ticket --\");\n    \n    _this.ticketsel.el.set_active_iter(iter);\n    \n    if (_this.ticket != null &&  _this.ticket.id == \"-1\") {\n\t\tel.append(out iter);\n\t\tel.set_value(iter, 0, \"-1\");\n\t\tel.set_value(iter, 1, \"Temporary Branch - No ticket specified/relivant\");\n        _this.ticketsel.el.set_active_iter(iter);\t\n    }\n    \n    \n    \n    \n    var tickets = RooTicket.singleton().tickets;\n    foreach(var ticket in tickets) {\n    \n        el.append(out iter);\n\n        el.set_value(iter, 0, ticket.id);\n        el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n\t\tif (_this.ticket != null && _this.ticket.id == ticket.id) {\n\t\t    _this.ticketsel.el.set_active_iter(iter);\n\t    }\n        \n    }\n    \n    _this.ticketsel.loading = false;\n     //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
            "$ xns" : "Gtk"
     },
     {
      "label" : "Cancel",
-     "* pack" : "add_action_widget,0",
      "xtype" : "Button",
+     "* pack" : "add_action_widget,0",
      "Gtk.ReliefStyle relief" : "Gtk.ReliefStyle.NONE",
      "$ xns" : "Gtk"
     },
     {
      "label" : "Do Merge",
-     "* pack" : "add_action_widget,1",
      "xtype" : "Button",
+     "* pack" : "add_action_widget,1",
      "$ xns" : "Gtk"
     }
    ]
   }
  ]
-}
+}
\ No newline at end of file
index 43820cc..a0aa781 100644 (file)
@@ -499,12 +499,21 @@ public class MergeBranch : Object
             var el = this.el;
             
             el.append(out iter);
-        
-            
             el.set_value(iter, 0, "");
             el.set_value(iter, 1, "-- select a ticket --");
             
             _this.ticketsel.el.set_active_iter(iter);
+            
+            if (_this.ticket != null &&  _this.ticket.id == "-1") {
+                       el.append(out iter);
+                       el.set_value(iter, 0, "-1");
+                       el.set_value(iter, 1, "Temporary Branch - No ticket specified/relivant");
+                _this.ticketsel.el.set_active_iter(iter);      
+            }
+            
+            
+            
+            
             var tickets = RooTicket.singleton().tickets;
             foreach(var ticket in tickets) {
             
@@ -512,7 +521,7 @@ public class MergeBranch : Object
         
                 el.set_value(iter, 0, ticket.id);
                 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
-                       if (_this.ticket.id == ticket.id) {
+                       if (_this.ticket != null && _this.ticket.id == ticket.id) {
                            _this.ticketsel.el.set_active_iter(iter);
                    }
                 
index 54fd0ef..a9c59a8 100644 (file)
@@ -10,7 +10,7 @@
   {
    "listeners" : {
     "delete_event" : "(self, event) => {\n    this.el.hide();\n    return true; \n    //test  \n}\n ",
-    "response" : " (self, response_id) =>  { \n  \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t    _this.el.hide();\t\n\t    this.running = false; \n\t \treturn;\n\t}\n\t \n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n    if (this.repo != null) {\n    \tvar bn = _this.name.el.get_text();\n    \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n    }\n\n    this.running = false; \n\n\tthis.el.hide();\n\t \n\t \n\n\t \n}",
+    "response" : " (self, response_id) =>  { \n  \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t    _this.el.hide();\t\n\t    this.running = false; \n\t \treturn;\n\t}\n\t \n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n    if (this.repo != null) {\n    \tvar bn = _this.name.el.get_text();\n    \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(\"-1\"), bn);\n\t\t}\n    }\n\n    this.running = false; \n\n\tthis.el.hide();\n\t \n\t \n\n\t \n}",
     "show" : "(self)  => {\n \n\n  //test\n}"
    },
    "default_width" : 500,
@@ -32,8 +32,8 @@
      "items" : [
       {
        "bool homogeneous" : false,
-       "* pack" : "pack_start,false,false,0",
        "xtype" : "Table",
+       "* pack" : "pack_start,false,false,0",
        "uint column_spacing" : 2,
        "n_columns" : 2,
        "$ xns" : "Gtk",
          "items" : [
           {
            "id" : "dbcellrenderer",
-           "xtype" : "CellRendererText",
            "* pack" : "pack_start,true",
+           "xtype" : "CellRendererText",
            "$ xns" : "Gtk"
           },
           {
            "id" : "dbmodel",
-           "xtype" : "ListStore",
            "* pack" : "set_model",
+           "xtype" : "ListStore",
            "| void loadTickets" : "  () {\n\n    RooTicket.singleton().loadTickets();\n    \n    _this.ticketsel.loading = true;\n\n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n    el.append(out iter);\n\n    \n    el.set_value(iter, 0, \"\");\n    el.set_value(iter, 1, \"-- select a ticket --\");\n    \n    _this.ticketsel.el.set_active_iter(iter);\n    var tickets = RooTicket.singleton().tickets;\n    foreach(var ticket in tickets) {\n    \n        el.append(out iter);\n        \n        el.set_value(iter, 0, ticket.id);\n        el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n        \n        //if (data.get(i) == cur) {\n         //   _this.build_module.el.set_active_iter(iter);\n       // }\n        \n    }\n    \n    _this.ticketsel.loading = false;\n     //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
     },
     {
      "label" : "Do not create Branch",
-     "xtype" : "Button",
      "* pack" : "add_action_widget,0",
+     "xtype" : "Button",
      "Gtk.ReliefStyle relief" : "Gtk.ReliefStyle.NONE",
      "$ xns" : "Gtk"
     },
     {
      "label" : "Create Branch",
-     "xtype" : "Button",
      "* pack" : "add_action_widget,1",
+     "xtype" : "Button",
      "$ xns" : "Gtk"
     }
    ]
index 7617e45..602922e 100644 (file)
@@ -78,7 +78,7 @@ public class NewBranch : Object
                if (ticket_id != "" ) {
                                this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
                        } else {
-                               this.repo.createBranchNamed(bn);
+                               this.repo.setActiveTicket( RooTicket.singleton().getById("-1"), bn);
                        }
             }
         
index 604d435..c4c71bd 100644 (file)
@@ -64,6 +64,18 @@ public class RooTicket : Object
                GLib.debug("ADD ticket  %s : %s : %s", add.id, add.summary, add.project_id_name);
                return add;
        }
+       
+       public static RooTicket fakeTicket()
+       {
+               var t = new RooTicket();
+               t.id = "-1";
+               t.summary = "";
+               t.description = "";
+               t.project_id_name = "";
+               RooTicket.singleton().tickets.add(t);
+               return t;
+       }
+       
  
        public RooTicket? getById(string id)
        {
@@ -72,6 +84,10 @@ public class RooTicket : Object
                                return t;
                        }
                }
+               if (id == "-1") {
+                       return RooTicket.fakeTicket();
+               }
+               
         return this.loadTicket(id);
 
  
@@ -207,50 +223,51 @@ public class RooTicket : Object
        }
 
 
-       public void close(string commits)
-       {
-               var table = new GLib.HashTable<string, string>(str_hash, str_equal);
-               table.insert("id",id);
-               table.insert("status_name","resolved");
-               table.insert("reason","fixed by Commits: %s".printf(commits));  
-               var params = Soup.Form.encode_hash(table);              
+       public void close(string commits)
+    {
+               if (this.id == "-1") {
+                       return;
+               }
+               var table = new GLib.HashTable<string, string>(str_hash, str_equal);
+               table.insert("id",id);
+               table.insert("status_name","resolved");
+               table.insert("reason","fixed by Commits: %s".printf(commits));  
+               var params = Soup.Form.encode_hash(table);              
 
-               GLib.debug("request POST %s / %s", baseurl, id);
-               
-               var session = new Soup.Session ();
-               session.timeout = 0;
-               var message = new Soup.Message ("POST", baseurl);
-               RooTicket.setAuth(message);
-                
-               message.set_request ("application/x-www-form-urlencoded", Soup.MemoryUse.STATIC, params.data);
-               session.send_message (message);
-               
-               
-               var data = (string) message.response_body.flatten().data;
-               GLib.debug("got %s", data);
-               try {
-                       var parser = new Json.Parser ();
-                       parser.load_from_data (data, -1);
+               GLib.debug("request POST %s / %s", baseurl, id);
 
-                       var response = parser.get_root().get_object();
-                       var status = response.get_boolean_member("success");
-               
-                       if(!status){
-                               GLib.error(response.get_string_member("errorMsg"));
-                               return ;
-                       }
-                        
-                       
-                        
-               
-               } catch (Error e) {
-                       GLib.error(e.message);
-                       return ;
-               }
-       
-       }
+               var session = new Soup.Session ();
+               session.timeout = 0;
+               var message = new Soup.Message ("POST", baseurl);
+               RooTicket.setAuth(message);
 
+               message.set_request ("application/x-www-form-urlencoded", Soup.MemoryUse.STATIC, params.data);
+               session.send_message (message);
+
+
+               var data = (string) message.response_body.flatten().data;
+               GLib.debug("got %s", data);
+               try {
+                          var parser = new Json.Parser ();
+                          parser.load_from_data (data, -1);
+
+                          var response = parser.get_root().get_object();
+                          var status = response.get_boolean_member("success");
+
+                          if(!status){
+                                          GLib.error(response.get_string_member("errorMsg"));
+                                          return ;
+                          }
+                               
+                          
+                               
+
+               } catch (Error e) {
+                          GLib.error(e.message);
+                          return ;
+               }
+
+   }
 
        
-       
- }
+}