From 613912c2357f311dbac1d88dbced1b95fa5c20f4 Mon Sep 17 00:00:00 2001 From: svkalinin Date: Fri, 21 Oct 2022 14:01:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=20=D1=81=D0=BE=D0=B7=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20git-=D0=B2?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/git.tcl | 64 ++++++++++++++++++++++++++++++++++++++++++++--------- lib/gui.tcl | 4 +++- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/lib/git.tcl b/lib/git.tcl index 63ff71d..db55cba 100644 --- a/lib/git.tcl +++ b/lib/git.tcl @@ -45,7 +45,7 @@ namespace eval Git { return $res } - proc Branches {opt {ent ".branch.entBranch"}} { + proc Checkout {opt {ent ".branch.entBranch"}} { global cfgVariables activeProject set cmd exec set d [pwd] @@ -53,23 +53,55 @@ namespace eval Git { cd $activeProject } lappend cmd $cfgVariables(gitCommand) + lappend cmd "checkout" + # lappend cmd "-s" + # lappend cmd "--" + # lappend cmd $activeProject + switch $opt { + switchBranch { + set branch [.branch.lBox get [.branch.lBox curselection]] + lappend cmd "[string trim $branch]" + } + new { + lappend cmd "-b" + lappend cmd "[$ent get]" + # puts "Branch [$ent get]" + } + } + catch $cmd pipe + puts $cmd + puts $pipe + if [regexp -nocase -- {^fatal:} $pipe match] { + return + } + foreach line [split $pipe "\n"] { + lappend res $line + } + cd $d + if [info exists res] { + return $res + } + } + + proc Branches {opt} { + global cfgVariables activeProject + set cmd exec + set d [pwd] + if {$activeProject ne ""} { + cd $activeProject + } + lappend cmd $cfgVariables(gitCommand) + lappend cmd "branch" # lappend cmd "-s" # lappend cmd "--" # lappend cmd $activeProject switch $opt { current { - lappend cmd "branch" lappend cmd "--show-current" } list { - lappend cmd "branch" lappend cmd "-l" } - new { - lappend cmd "checkout" - lappend cmd "-b" - puts "Branch [$ent get]" - } } catch $cmd pipe if [regexp -nocase -- {^fatal:} $pipe match] { @@ -413,7 +445,7 @@ namespace eval Git { -command { grid forget .branch.lBox .branch.yscroll grid .branch.entBranch - bind .branch "Git::Branches new .branch.entBranch; destroy .branch" + bind .branch "Git::Checkout new .branch.entBranch; destroy .branch" } ttk::entry $win.entBranch -textvariable newBranchName @@ -445,8 +477,17 @@ namespace eval Git { break } bind $win.lBox { + Git::Checkout switchBranch + .frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]" + destroy .branch } bind $win.lBox {} + bind $win.lBox { + Git::Checkout switchBranch + .frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]" + destroy .branch + } + # Определям расстояние до края экрана (основного окна) и если # оно меньше размера окна со списком то сдвигаем его вверх set winGeom [winfo reqheight $win] @@ -572,7 +613,10 @@ namespace eval Git { catch { $fr.body.lBox activate 0 ; $fr.body.lBox selection set 0 0 } - bind $fr.header.lblGit {catch [Git::BranchDialog %X %Y]} + bind $fr.header.lblGit { + Git::BranchDialog %X %Y + Git::DialogUpdate $Git::fr + } bind $fr.body.lBox "Git::CommitAdd $fr" bind $fr.body.lBox "catch {Git::CommitAdd $fr}" bind $fr.body.lBox "Git::ListBoxPress $fr" diff --git a/lib/gui.tcl b/lib/gui.tcl index 3a9936c..e449053 100644 --- a/lib/gui.tcl +++ b/lib/gui.tcl @@ -81,7 +81,9 @@ pack .frmStatus -side top -padx 1 -fill x #pack [label .frmMenu.lbl -text "ddd"] pack [ttk::label .frmStatus.lblGitLogo -justify left] -side left pack [ttk::label .frmStatus.lblGit] -side left -bind .frmStatus.lblGit {catch [Git::BranchDialog %X %Y]} +bind .frmStatus.lblGit { + Git::BranchDialog %X %Y +} pack [ttk::label .frmStatus.lblPosition -justify right] -side right