diff --git a/bin/gitlist1.1.1/.htaccess b/bin/gitlist1.1.1/.htaccess new file mode 100644 index 00000000..5969de66 --- /dev/null +++ b/bin/gitlist1.1.1/.htaccess @@ -0,0 +1,13 @@ + + Options -MultiViews +SymLinksIfOwnerMatch + + RewriteEngine On + RewriteBase /gitlist/ + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ index.php/$1 [L,NC] + + + order allow,deny + deny from all + diff --git a/bin/gitlist1.1.1/cache/.gitignore b/bin/gitlist1.1.1/cache/.gitignore new file mode 100644 index 00000000..005717ea --- /dev/null +++ b/bin/gitlist1.1.1/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/bin/gitlist1.1.1/config.ini b/bin/gitlist1.1.1/config.ini new file mode 100644 index 00000000..41f334b7 --- /dev/null +++ b/bin/gitlist1.1.1/config.ini @@ -0,0 +1,17 @@ +[git] +client = '~NEARD_LIN_PATH~/tools/git/git2.8.0/bin/git.exe' +repositories[] = '' + +[app] +debug = false +cache = false + +[filetypes] +; extension = type +; dist = xml + +[binary_filetypes] +; extension = true +; svh = false +; map = true + diff --git a/bin/gitlist1.1.1/neard.conf b/bin/gitlist1.1.1/neard.conf new file mode 100644 index 00000000..c2c43ecf --- /dev/null +++ b/bin/gitlist1.1.1/neard.conf @@ -0,0 +1,4 @@ +gitlistVersion = "0.6.0" +gitlistConf = "config.ini" + +bundleRelease = "@RELEASE_VERSION@" diff --git a/bin/gitlist1.1.1/src/Git/Client.php b/bin/gitlist1.1.1/src/Git/Client.php new file mode 100644 index 00000000..6372dad9 --- /dev/null +++ b/bin/gitlist1.1.1/src/Git/Client.php @@ -0,0 +1,245 @@ +setDefaultBranch($options['default_branch']); + $this->setHidden($options['hidden']); + $this->setProjects($options['projects']); + } + + public function getRepositoryFromName($paths, $repo) + { + $repositories = $this->getRepositories($paths); + $path = $repositories[$repo]['path']; + + return $this->getRepository($path); + } + + /** + * Searches for valid repositories on the specified path. + * + * @param array $paths Array of paths where repositories will be searched + * + * @return array Found repositories, containing their name, path and description sorted + * by repository name + */ + public function getRepositories($paths) + { + $allRepositories = []; + + foreach ($paths as $path) { + /*$repositories = $this->recurseDirectory($path); + + if (empty($repositories)) { + throw new \RuntimeException('There are no GIT repositories in ' . $path); + } + + // Use "+" to preserve keys, only a problem with numeric repos. + $allRepositories = $allRepositories + $repositories;*/ + + // START Neard edit + $name = str_replace(':', '', str_replace('/', '#', $path)); + $repositories[$name] = array( + 'name' => $name, + 'path' => $path, + 'description' => file_exists($path . '/.git/description') ? file_get_contents($path . '/.git/description') : '' + ); + + $allRepositories = array_merge($allRepositories, $repositories); + // END Neard edit + } + + $allRepositories = array_unique($allRepositories, SORT_REGULAR); + uksort($allRepositories, function ($k1, $k2) { + return strtolower($k2) < strtolower($k1); + }); + + return $allRepositories; + } + + /** + * Return name of default branch as a string. + */ + public function getDefaultBranch() + { + return $this->defaultBranch; + } + + /** + * Overloads the parent::createRepository method for the correct Repository class instance. + * + * {@inheritdoc} + */ + public function createRepository($path, $bare = null) + { + if (file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) { + throw new \RuntimeException('A GIT repository already exists at ' . $path); + } + + $repository = new Repository($path, $this); + + return $repository->create($bare); + } + + /** + * Overloads the parent::getRepository method for the correct Repository class instance. + * + * {@inheritdoc} + */ + public function getRepository($path) + { + if (!file_exists($path) || !file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) { + throw new \RuntimeException('There is no GIT repository at ' . $path); + } + + return new Repository($path, $this); + } + + /** + * Set default branch as a string. + * + * @param string $branch name of branch to use when repo's HEAD is detached + * + * @return object + */ + protected function setDefaultBranch($branch) + { + $this->defaultBranch = $branch; + + return $this; + } + + /** + * Get hidden repository list. + * + * @return array List of repositories to hide + */ + protected function getHidden() + { + return $this->hidden; + } + + /** + * Set the hidden repository list. + * + * @param array $hidden List of repositories to hide + * + * @return object + */ + protected function setHidden($hidden) + { + $this->hidden = $hidden; + + return $this; + } + + /** + * Get project list. + * + * @return array List of repositories to show + */ + protected function getProjects() + { + return $this->projects; + } + + /** + * Set the shown repository list. + * + * @param array $projects List of repositories to show + */ + protected function setProjects($projects) + { + $this->projects = $projects; + + return $this; + } + + private function recurseDirectory($path, $topLevel = true) + { + $dir = new \DirectoryIterator($path); + + $repositories = []; + + foreach ($dir as $file) { + if ($file->isDot()) { + continue; + } + + if (strrpos($file->getFilename(), '.') === 0) { + continue; + } + + if (!$file->isReadable()) { + continue; + } + + if ($file->isDir()) { + $isBare = file_exists($file->getPathname() . '/HEAD'); + $isRepository = file_exists($file->getPathname() . '/.git/HEAD'); + + if ($isRepository || $isBare) { + $hidden = function ($path, $hide) { + $return = false; + + array_walk($hide, function ($value, $key) use ($path, &$return) { + if (($path === $value) || (1 === preg_match($value, $path))) { + $return = true; + } + }); + + return $return; + }; + + if ($hidden($file->getPathname(), $this->getHidden())) { + continue; + } + + if ($isBare) { + $description = $file->getPathname() . '/description'; + } else { + $description = $file->getPathname() . '/.git/description'; + } + + if (file_exists($description)) { + $description = file_get_contents($description); + } else { + $description = null; + } + + if (!$topLevel) { + $repoName = $file->getPathInfo()->getFilename() . '/' . $file->getFilename(); + } else { + $repoName = $file->getFilename(); + } + + if (is_array($this->getProjects()) && !in_array($repoName, $this->getProjects())) { + continue; + } + + $repositories[$repoName] = [ + 'name' => $repoName, + 'path' => $file->getPathname(), + 'description' => $description, + ]; + + continue; + } + $repositories = array_merge($repositories, $this->recurseDirectory($file->getPathname(), false)); + } + } + + return $repositories; + } +} diff --git a/bin/gitlist2.0.0/bearsampp.conf b/bin/gitlist2.0.0/bearsampp.conf index b599bc7d..4b86f5e3 100644 --- a/bin/gitlist2.0.0/bearsampp.conf +++ b/bin/gitlist2.0.0/bearsampp.conf @@ -1,4 +1,4 @@ -gitlistVersion = "2.0.0" +gitlistVersion = "1.1.1" gitlistConf = "config.ini" bundleRelease = "@RELEASE_VERSION@" diff --git a/build.properties b/build.properties index 7a9c3462..4d039fbf 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ bundle.name = gitlist -bundle.release = 2022.07.11 +bundle.release = 1.1.1 bundle.type = apps bundle.format = 7z