From 74baff89f6e20ba23ef2327911bb1c64b8453a0a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 16 2016 08:30:54 +0000 Subject: There is no reason to always block project with 40 chars project name Instances that are recent enough do not need this restriction, we only use it on old instances to keep backward compatibility on URLs of commits --- diff --git a/pagure/api/project.py b/pagure/api/project.py index 5bd1ae4..5300d07 100644 --- a/pagure/api/project.py +++ b/pagure/api/project.py @@ -248,6 +248,8 @@ def api_new_project(): requestfolder=APP.config['REQUESTS_FOLDER'], add_readme=create_readme, userobj=user, + prevent_40_chars=APP.config.get( + 'OLD_VIEW_COMMIT_ENABLED', False), ) SESSION.commit() pagure.lib.git.generate_gitolite_acls() diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 76ee859..74398cf 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -979,7 +979,8 @@ def add_pull_request_flag(session, request, username, percent, comment, url, def new_project(session, user, name, blacklist, allowed_prefix, gitfolder, docfolder, ticketfolder, requestfolder, description=None, url=None, avatar_email=None, - parent_id=None, add_readme=False, userobj=None): + parent_id=None, add_readme=False, userobj=None, + prevent_40_chars=False): ''' Create a new project based on the information provided. ''' if name in blacklist: @@ -998,7 +999,8 @@ def new_project(session, user, name, blacklist, allowed_prefix, 'prefix set by the admins of this pagure instance, or the name ' 'of a group that you are part of.' ) - if len(second_part) == 40: + + if len(second_part) == 40 and not prevent_40_chars: # We must block project with a name / where the length # of is exactly 40 characters long as this would otherwise # conflict with the old URL schema used for commit that was diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 636ea0c..cc6ab17 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -392,6 +392,8 @@ def get_project_from_json( docfolder=docfolder, ticketfolder=ticketfolder, requestfolder=requestfolder, + prevent_40_chars=pagure.APP.config.get( + 'OLD_VIEW_COMMIT_ENABLED', False), ) session.commit() diff --git a/pagure/ui/app.py b/pagure/ui/app.py index b688dd6..a395e4a 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -391,6 +391,8 @@ def new_project(): requestfolder=APP.config['REQUESTS_FOLDER'], add_readme=create_readme, userobj=user, + prevent_40_chars=APP.config.get( + 'OLD_VIEW_COMMIT_ENABLED', False), ) SESSION.commit() pagure.lib.git.generate_gitolite_acls()