Repository: mozilla/pontoon

Issue:
Reading configuration toml file from the repository
I have a private GitLab repository and trying to setup Pontoon for localization. I have added needed SSH keys and sync is working. 

I'm trying to add a project configuration file now as I need to configure `[[paths]]`.

Problem that I'm facing is that Pontoon only allows using toml config file when repository permalink is set. I cannot do that for a private repository.

Is it possible to make Pontoon read config file from the repository itself?


Discussion:

Resolving patch:
diff --git a/pontoon/sync/vcs/models.py b/pontoon/sync/vcs/models.py
--- a/pontoon/sync/vcs/models.py
+++ b/pontoon/sync/vcs/models.py
@@ -84,13 +84,6 @@ def parse(self, path=None, env=None, ignore_missing_includes=True):
         )
 
 
-class MissingRepositoryPermalink(Exception):
-    """
-    Raised when a project uses project config files and
-    its source repository doesn't have the permalink.
-    """
-
-
 class MissingSourceRepository(Exception):
     """
     Raised when project can't find the repository
@@ -168,10 +161,6 @@ def __init__(
 
         self.configuration = None
         if db_project.configuration_file:
-            # Permalink is required to download project config files.
-            if not db_project.source_repository.permalink_prefix:
-                raise MissingRepositoryPermalink()
-
             self.configuration = VCSConfiguration(self)
 
     @cached_property
@@ -634,11 +623,23 @@ def l10n_base(self):
     @cached_property
     def parsed_configuration(self):
         """Return parsed project configuration file."""
-        return DownloadTOMLParser(
-            self.vcs_project.db_project.source_repository.checkout_path,
-            self.vcs_project.db_project.source_repository.permalink_prefix,
-            self.configuration_file,
-        ).parse(env={"l10n_base": self.l10n_base})
+        if self.vcs_project.db_project.source_repository.permalink_prefix:
+            """If we have a permalink we download the configuration file"""
+            return DownloadTOMLParser(
+                self.vcs_project.db_project.source_repository.checkout_path,
+                self.vcs_project.db_project.source_repository.permalink_prefix,
+                self.configuration_file,
+            ).parse(env={"l10n_base": self.l10n_base})
+        else:
+            """If we don't have a permalink we use the configuration file from the checkout path"""
+            return TOMLParser().parse(
+                os.path.join(
+                    self.vcs_project.db_project.source_repository.checkout_path,
+                    self.configuration_file,
+                ),
+                env={"l10n_base": self.l10n_base},
+                ignore_missing_includes=True,
+            )
 
     def add_locale(self, locale_code):
         """


Test patch:
diff --git a/pontoon/sync/tests/test_vcs_models.py b/pontoon/sync/tests/test_vcs_models.py
--- a/pontoon/sync/tests/test_vcs_models.py
+++ b/pontoon/sync/tests/test_vcs_models.py
@@ -26,7 +26,6 @@
     VCSTranslationFactory,
 )
 from pontoon.sync.vcs.models import (
-    MissingRepositoryPermalink,
     VCSConfiguration,
     VCSResource,
     VCSProject,
@@ -122,19 +121,6 @@ def test_get_relevant_files_without_config(self):
 
         assert files == {"path/to/localizable_file.ftl": ["XY"]}
 
-    def test_missing_permalink_prefix(self):
-        """
-        Fail when the source repository of a project with the project
-        config doesn't have the permalink defined.
-        """
-        with self.assertRaises(MissingRepositoryPermalink):
-            self.project.configuration_file = "l10n.toml"
-            self.project.source_repository.permalink_prefix = ""
-            self.project.source_repository.save()
-            VCSProject(
-                self.project,
-            )
-
     def test_relative_resource_paths(self):
         with patch.object(
             VCSProject,