Merge pull request #14656 from nupplaphil/feat/fix-codestyle

Add `bin/dev/fix-codestyle.sh`
This commit is contained in:
Hypolite Petovan 2025-01-01 21:01:34 -05:00 committed by GitHub
commit 092958441b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 2 deletions

View file

@ -39,6 +39,7 @@ steps:
check: check:
image: php:8.3 image: php:8.3
commands: commands:
- echo "**** Use bin/dev/fix-codestyle.sh in case of errors ****"
- apt-get update -q - apt-get update -q
- DEBIAN_FRONTEND=noninteractive apt-get install -q -y git - DEBIAN_FRONTEND=noninteractive apt-get install -q -y git
- if [ ! -z "$${CI_COMMIT_PULL_REQUEST}" ]; then - if [ ! -z "$${CI_COMMIT_PULL_REQUEST}" ]; then

24
bin/dev/fix-codestyle.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2010-2025 the Friendica project
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# this script checks or fixes php-files, based on the php-cs rules
#
# You can use the following variables:
# COMMAND ... the php-cs command to execute (default is "check --diff")
# TARGET_BRANCH ... set the target branch for the current branch to create a diff between them
#
##
COMMAND=${COMMAND:-"check --diff"}
if [ -n "${TARGET_BRANCH}" ]; then
CHANGED_FILES="$(git diff --name-only --diff-filter=ACMRTUXB "$(git ls-remote -q | grep refs/heads/"${TARGET_BRANCH}"$ | awk '{print $1}' | xargs git rev-parse )".."$(git rev-parse HEAD)")";
else
CHANGED_FILES="$(git diff --name-only --diff-filter=ACMRTUXB "$(git rev-parse HEAD)")";
fi
EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}");
./bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer ${COMMAND} --config=.php-cs-fixer.dist.php -v --using-cache=no ${EXTRA_ARGS}

View file

@ -537,7 +537,7 @@ class App
$requeststring = ($serverVars['REQUEST_METHOD'] ?? '') . ' ' . ($serverVars['REQUEST_URI'] ?? '') . ' ' . ($serverVars['SERVER_PROTOCOL'] ?? ''); $requeststring = ($serverVars['REQUEST_METHOD'] ?? '') . ' ' . ($serverVars['REQUEST_URI'] ?? '') . ' ' . ($serverVars['SERVER_PROTOCOL'] ?? '');
$this->logger->debug('Request received', ['address' => $serverVars['REMOTE_ADDR'] ?? '', 'request' => $requeststring, 'referer' => $serverVars['HTTP_REFERER'] ?? '', 'user-agent' => $serverVars['HTTP_USER_AGENT'] ?? '']); $this->logger->debug('Request received', ['address' => $serverVars['REMOTE_ADDR'] ?? '', 'request' => $requeststring, 'referer' => $serverVars['HTTP_REFERER'] ?? '', 'user-agent' => $serverVars['HTTP_USER_AGENT'] ?? '']);
$request_start = microtime(true); $request_start = microtime(true);
$request = $_REQUEST; $request = $_REQUEST;
$this->profiler->set($start_time, 'start'); $this->profiler->set($start_time, 'start');
$this->profiler->set(microtime(true), 'classinit'); $this->profiler->set(microtime(true), 'classinit');
@ -701,7 +701,7 @@ class App
$router = $this->container->create(Router::class); $router = $this->container->create(Router::class);
$moduleClass = $moduleClass ?? $router->getModuleClass(); $moduleClass = $moduleClass ?? $router->getModuleClass();
$parameters = $router->getParameters(); $parameters = $router->getParameters();
$dice_profiler_threshold = $this->config->get('system', 'dice_profiler_threshold', 0); $dice_profiler_threshold = $this->config->get('system', 'dice_profiler_threshold', 0);