From 4a7dd62054358df93a5f47f3c5abde2a2f299c4a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 16 2018 10:21:29 +0000 Subject: [PATCH 1/2] Make configurable the size of files above which syntax highlighting is dropped Fixes https://pagure.io/pagure/issue/3191 Signed-off-by: Pierre-Yves Chibon --- diff --git a/doc/configuration.rst b/doc/configuration.rst index 035a481..ce38745 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1261,6 +1261,17 @@ validate new project name. Defaults to: ``^[a-zA-z0-9_][a-zA-Z0-9-_]*$`` +FILE_SIZE_HIGHLIGHT +~~~~~~~~~~~~~~~~~~~ + +This configuration key allows to specify the maximum number of characters a file +or diff should have to have syntax highlighting. Everything above this limit +will not have syntax highlighting as this is a memory intensive procedure that +easily leads to out of memory error on large files or diff. + +Defaults to: 5000 + + Deprecated configuration keys ----------------------------- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 2574c94..c4840b5 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -70,10 +70,6 @@ from pagure.decorators import ( _log = logging.getLogger(__name__) -# Number of characters to determine that a file is "huge" -# Huge files will not get syntax highlighting -HUGEFILE = 5000 - def get_git_url_ssh(): """ Return the GIT SSH URL to be displayed in the UI based on the @@ -560,7 +556,8 @@ def view_file(repo, identifier, filename, username=None, namespace=None): content, safe = pagure.doc_utils.convert_readme(content.data, ext) output_type = 'markup' elif 'data' in dir(content) \ - and len(content.data) < HUGEFILE \ + and len(content.data) < pagure_config.get( + 'FILE_SIZE_HIGHLIGHT', 5000) \ and not isbinary: file_content = None try: From c93a4876dd227ebd3c63627bc814ffb936443130 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 16 2018 10:21:29 +0000 Subject: [PATCH 2/2] Some consistency in our white lines Signed-off-by: Pierre-Yves Chibon --- diff --git a/doc/configuration.rst b/doc/configuration.rst index ce38745..11e260d 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1041,6 +1041,7 @@ this pagure instance does not have a documentation server. Defaults to: ``None`` + PRIVATE_PROJECTS ~~~~~~~~~~~~~~~~ @@ -1088,6 +1089,7 @@ Defaults to: ``['pretty please pagure-ci rebuild']`` .. note:: The sentences defined in this configuration key should be lower case only! + FLAG_STATUSES_LABELS ~~~~~~~~~~~~~~~~~~~~ @@ -1095,6 +1097,7 @@ By default, Pagure has ``success``, ``failure``, ``error``, ``pending`` and ``canceled`` statuses of PR and commit flags. This setting allows you to define a custom mapping of statuses to their respective Bootstrap labels. + FLAG_SUCCESS ~~~~~~~~~~~~ @@ -1102,6 +1105,7 @@ Holds name of PR/commit flag that is considered a success. Defaults to: ``success`` + FLAG_FAILURE ~~~~~~~~~~~~ @@ -1109,6 +1113,7 @@ Holds name of PR/commit flag that is considered a failure. Defaults to: ``failure`` + FLAG_PENDING ~~~~~~~~~~~~ @@ -1116,6 +1121,7 @@ Holds name of PR/commit flag that is considered a pending state. Defaults to: ``pending`` + EXTERNAL_COMMITTER ~~~~~~~~~~~~~~~~~~ @@ -1158,6 +1164,7 @@ To give access to just some projects (named ``rpms/test`` and } } + REQUIRED_GROUPS ~~~~~~~~~~~~~~~ @@ -1190,6 +1197,7 @@ With this configuration (evaluated in the provided order): * only users in the ``contributor`` group will be allowed to be added to any project on this pagure instance. + GITOLITE_PRE_CONFIG ~~~~~~~~~~~~~~~~~~~