diff --git a/lib/config.tcl b/lib/config.tcl index 5caef88..88753cc 100644 --- a/lib/config.tcl +++ b/lib/config.tcl @@ -25,7 +25,7 @@ set ::configDefault "\[General\] cfgModifyDate='' searchCommand=/usr/bin/grep searchCommandOptions=-r -n -H -gitCommand=/usr/bin/git +gitCommand= # must return a mime type of file fileTypeCommand=/usr/bin/file fileTypeCommandOptions=-i -b diff --git a/lib/git.tcl b/lib/git.tcl index 0a1897a..daaa59d 100644 --- a/lib/git.tcl +++ b/lib/git.tcl @@ -11,7 +11,29 @@ namespace eval Git { variable gitCommand - + + # Определим путь до команды git в зависимсти от платформы + proc CommandPathSetting {} { + global cfgVariables tcl_platform + if {$cfgVariables(gitCommand) == ""} { + if {$tcl_platform(platform) eq "windows"} { + set cmd {where git} + } else { + set cmd {which git} + } + if {[catch {exec {*}$cmd} git_path]} { + puts "Git не найден в системе" + set cfgVariables(gitCommand) "Git not found" + return + } + set git_path [string trim $git_path] + set first_path [lindex [split $git_path "\n"] 0] + + # puts "Git найден: $first_path" + set cfgVariables(gitCommand) $first_path + } + } + proc GetConfig {option} { global activeProject cfgVariables set confOptions { diff --git a/projman.tcl b/projman.tcl index 3e0cc1f..952ce7a 100755 --- a/projman.tcl +++ b/projman.tcl @@ -112,6 +112,8 @@ puts "Setting the locale... [::msgcat::mclocale]" source [file join $dir(lib) gui.tcl] +Git::CommandPathSetting + # Open the PATH if command line argument has been setting if [info exists opened] { foreach path $opened { @@ -147,3 +149,4 @@ if [info exists opened] { } } } +