Repository: WeblateOrg/weblate

Issue:
Default GitHub repo configuration doesn’t create PR
**Describe the bug**
Default GitHub repository configuration of translation project in not creating pull requests

**To Reproduce**
Steps to reproduce the behavior:
1. Set up a translation profile
2. In its VCS configuration, left `Repository push URL` empty
3. Try to push changes to the remote repository.

**Expected behavior**
The Default GitHub repository configuration of translation project is creating PR in the remote repo when `Repository push URL` field on https://hosted.weblate.org/settings/<project>/<component>/#vcs is empty.

The `Push` button on https://hosted.weblate.org/settings/<project>/<component>/#repository works when no push URL is set up.



<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/90847622-default-github-repo-configuration-doesn-t-create-pr?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github).
</bountysource-plugin>


Discussion:
Setting of push URL is currently required even though it won't be used in this particular case.

The logic for enabling push is currently pretty simple:

https://github.com/WeblateOrg/weblate/blob/b19d4bd0834411ec5963a0f835f48730238466e1/weblate/trans/models/component.py#L685-L688

It should also consider configured VCS backend and query it whether it is okay to push even with empty push URL.

Resolving patch:
diff --git a/weblate/trans/models/component.py b/weblate/trans/models/component.py
--- a/weblate/trans/models/component.py
+++ b/weblate/trans/models/component.py
@@ -855,7 +855,7 @@ def _get_path(self):
     @perform_on_link
     def can_push(self):
         """Return true if push is possible for this component."""
-        return bool(self.push)
+        return bool(self.push) or not self.repository.needs_push_url
 
     @property
     def is_repo_link(self):
diff --git a/weblate/vcs/base.py b/weblate/vcs/base.py
--- a/weblate/vcs/base.py
+++ b/weblate/vcs/base.py
@@ -68,6 +68,7 @@ class Repository:
     name = None
     req_version = None
     default_branch = ""
+    needs_push_url = True
 
     _version = None
 
diff --git a/weblate/vcs/git.py b/weblate/vcs/git.py
--- a/weblate/vcs/git.py
+++ b/weblate/vcs/git.py
@@ -401,6 +401,8 @@ class SubversionRepository(GitRepository):
 
     _fetch_revision = None
 
+    needs_push_url = False
+
     @classmethod
     def _get_version(cls):
         """Return VCS program version."""
@@ -523,6 +525,8 @@ def push(self):
 
 
 class GitMergeRequestBase(GitRepository):
+    needs_push_url = False
+
     @staticmethod
     def get_username():
         raise NotImplementedError()
@@ -562,7 +566,7 @@ def push(self):
                 self.component.project.slug, self.component.slug
             )
         else:
-            fork_branch = "{0}-weblate".format(self.branch)
+            fork_branch = "weblate-{0}".format(self.branch)
         self.push_to_fork(self.branch, fork_branch)
         try:
             self.create_pull_request(self.branch, fork_branch)


Test patch: