From 7aaf423fdb08a5a13689f014ec8e2c3ba1e3e27e Mon Sep 17 00:00:00 2001 From: Hiago Hubert Date: Mon, 12 Dec 2016 21:30:04 -0300 Subject: [PATCH 1/3] added warning if b374k is running under a git repository --- base/layout.php | 6 ++++++ base/main.php | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/base/layout.php b/base/layout.php index 5933448..16c64da 100644 --- a/base/layout.php +++ b/base/layout.php @@ -24,6 +24,7 @@ #tobottom{-webkit-transform:scaleY(-1);-moz-transform:scaleY(-1);-o-transform:scaleY(-1);transform:scaleY(-1);filter:FlipV;-ms-filter:"FlipV";} #showinfo{float:right;display:none;} #logout{float:right;} +.git_alert{font-weight: bold; color:#ef793e; font-size: 16px;} @@ -64,6 +65,11 @@ foreach(get_server_info() as $k=>$v){ echo "
".$v."
"; } + + if(is_git_repo(getcwd())){ + echo "

Warning: b374k is running under a git repository!

+ Click here to hide b374k from git "; + } ?> diff --git a/base/main.php b/base/main.php index e26d9f5..f6f4f49 100644 --- a/base/main.php +++ b/base/main.php @@ -985,4 +985,16 @@ if(!function_exists('output')){ die(); } } + + +if(!function_exists('is_git_repo')){ + function is_git_repo($path){ + if(is_dir($path. DIRECTORY_SEPARATOR .".git")){ + return true; + } + return false; + } +} + + ?> \ No newline at end of file From 0d4a31b2a798b31f1ad4b1bd39e3e646c1f20395 Mon Sep 17 00:00:00 2001 From: Hiago Hubert Date: Tue, 13 Dec 2016 00:08:23 -0300 Subject: [PATCH 2/3] finding git on parent's dir --- base/main.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/base/main.php b/base/main.php index f6f4f49..dc9445e 100644 --- a/base/main.php +++ b/base/main.php @@ -988,13 +988,23 @@ if(!function_exists('output')){ if(!function_exists('is_git_repo')){ - function is_git_repo($path){ - if(is_dir($path. DIRECTORY_SEPARATOR .".git")){ - return true; - } - return false; + function is_git_repo(){ + return boolval( find_git_repo(dirname(__FILE__)) ); } } +if(!function_exists('find_git_repo')){ + function find_git_repo($path){ + if(dirname($path) == DIRECTORY_SEPARATOR){ + return false; + }else if( is_dir(getcwd().DIRECTORY_SEPARATOR.".git") ){ + return getcwd().DIRECTORY_SEPARATOR.".git"; + }else if(is_dir(dirname($path).DIRECTORY_SEPARATOR.".git")){ + return dirname($path).DIRECTORY_SEPARATOR.".git"; + }else{ + return find_git_repo(dirname($path)); + } + } +} ?> \ No newline at end of file From 3d7022a7da94befdabac646b395a1a488c0300ec Mon Sep 17 00:00:00 2001 From: Hiago Hubert Date: Tue, 13 Dec 2016 00:33:35 -0300 Subject: [PATCH 3/3] Optimizing function --- base/main.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/base/main.php b/base/main.php index dc9445e..156bc25 100644 --- a/base/main.php +++ b/base/main.php @@ -989,7 +989,7 @@ if(!function_exists('output')){ if(!function_exists('is_git_repo')){ function is_git_repo(){ - return boolval( find_git_repo(dirname(__FILE__)) ); + return boolval( find_git_repo(getcwd().DIRECTORY_SEPARATOR.".git") ); } } @@ -997,8 +997,6 @@ if(!function_exists('find_git_repo')){ function find_git_repo($path){ if(dirname($path) == DIRECTORY_SEPARATOR){ return false; - }else if( is_dir(getcwd().DIRECTORY_SEPARATOR.".git") ){ - return getcwd().DIRECTORY_SEPARATOR.".git"; }else if(is_dir(dirname($path).DIRECTORY_SEPARATOR.".git")){ return dirname($path).DIRECTORY_SEPARATOR.".git"; }else{