Browse code

Allows to hide repos with regex

Nicolas Da Mutten authored on01/08/2017 16:45:44
Showing2 changed files
... ...
@@ -8,7 +8,7 @@ repositories[] = '/home/git/repositories/' ; Path to your repositories
8 8
 ;client = '"C:\Program Files (x86)\Git\bin\git.exe"' ; Your git executable path
9 9
 ;repositories[] = 'C:\Path\to\Repos\' ; Path to your repositories
10 10
 
11
-; You can hide repositories from GitList, just copy this for each repository you want to hide
11
+; You can hide repositories from GitList, just copy this for each repository you want to hide or add a regex (including delimiters), eg. hidden[] = '/(.+)\.git/'
12 12
 ; hidden[] = '/home/git/repositories/BetaTest'
13 13
 
14 14
 [app]
... ...
@@ -82,7 +82,20 @@ class Client extends BaseClient
82 82
                 $isRepository = file_exists($file->getPathname() . '/.git/HEAD');
83 83
 
84 84
                 if ($isRepository || $isBare) {
85
-                    if (in_array($file->getPathname(), $this->getHidden())) {
85
+	                
86
+	                $hidden = function($path, $hide) {
87
+		                
88
+		                $return = false;
89
+		                
90
+		                array_walk($hide, function($value, $key) use ($path, &$return) {
91
+			                if ( ($path === $value) || (1 === preg_match($value, $path)) ) {
92
+				                $return = true;
93
+						    }
94
+		                });
95
+		                return $return;
96
+	                };
97
+	                
98
+                    if ($hidden($file->getPathname(), $this->getHidden())) {
86 99
                         continue;
87 100
                     }
88 101