From ca8ff0bc1a4716f37a8df38500123d134cd1e5e2 Mon Sep 17 00:00:00 2001 From: Ricardo Barbedo Date: Wed, 4 Jan 2017 21:45:22 -0200 Subject: [PATCH] Change to the project directory when using the git wrapper --- scripts/git_wrapper.tcl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/git_wrapper.tcl b/scripts/git_wrapper.tcl index 32e6f7f..c80a08a 100644 --- a/scripts/git_wrapper.tcl +++ b/scripts/git_wrapper.tcl @@ -18,6 +18,17 @@ namespace eval ::git_wrapper { proc git {args} { set command [lindex $args 0] + # Change directory project directory if not in it yet + set proj_dir [regsub {\/work$} [get_property DIRECTORY [current_project]] {}] + set current_dir [pwd] + if { + [string compare -nocase $proj_dir $current_dir] + } then { + puts "Not in project directory" + puts "Changing directory to: ${proj_dir}" + cd $proj_dir + } + switch $command { "init" {git_init {*}$args} "commit" {git_commit {*}$args} @@ -47,4 +58,4 @@ namespace eval ::git_wrapper { # Now commit everything exec git {*}$args } -} \ No newline at end of file +}