Repository: pymedusa/Medusa

Issue:
Git origin.remote.pushurl invalid when using git_token and no git_username
**Branch/Commit:** Develop/0e2338b8b49cd018671b7e95823c749070cf3b7e
**OS:** Linux
**What you did:** Run medusa as a normal user(developer=0) with github login(token) info to be able to submit errors but without setting the git username
**What happened:** the git origin.remote.pushurl is now https://github.com//Medusa
**What you expected:** The url to be https://github.com/pymedusa/Medusa
**Logs:** N/A
**Function:** https://github.com/pymedusa/Medusa/blob/develop/medusa/version_checker.py#L743

Hello,

I would like to have your input on this before submitting a PR as I think the whole function should be changed instead of just fixing the missing if app.git_username.

My main issue with this function is that it set fetch and push to 2 different repos when app.developer is False(i.e. regular user) which should be a big no-no, see the following documentions:

https://github.com/git/git/commit/697f652818f211aa48e3c007f25d6177647980c1
https://git-scm.com/docs/git-remote#git-remote-emset-urlem

~~An other issue is why would anyone push directly to the main repo when in dev per default?~~

I think it shouldn't touch the remote.origin when developer=1 and should be something like this:
```
def update_remote_origin(self):
    if not app.DEVELOPER:
        self._run_git(self._git_path, 'config remote.%s.url %s' % (app.GIT_REMOTE, app.GIT_REMOTE_URL))
        self._run_git(self._git_path, 'config remote.%s.pushurl %s' % (app.GIT_REMOTE, app.GIT_REMOTE_URL))
```

Thank You in advance



Discussion:
hey @abeloin ! welcome back. 

I think we did this way so sickrage user's could migrate to pymedusa repository and make sure remote was changed.

feel free to open a PR. btw do you want to be contributor so you can create feature branches?
Hi @fernandog long time no see!

> I think we did this way so sickrage user's could migrate to pymedusa repository and make sure remote was changed.

I think the code in #3778 was the code added for the migration but it was rewrote a couple of time and lost its orignal purpose.

I'll open a PR after I understand how the dev process work because a lot have changed since the last time I contributed and I'm having issues using my forked repos for dev which I've ask for help in #3778.

~~removed~~

Resolving patch:
diff --git a/medusa/version_checker.py b/medusa/version_checker.py
--- a/medusa/version_checker.py
+++ b/medusa/version_checker.py
@@ -742,20 +742,7 @@ def list_remote_branches(self):
 
     def update_remote_origin(self):
         self._run_git(self._git_path, 'config remote.%s.url %s' % (app.GIT_REMOTE, app.GIT_REMOTE_URL))
-        if app.GIT_AUTH_TYPE == 0:
-            if app.GIT_USERNAME:
-                if app.DEVELOPER:
-                    self._run_git(self._git_path, 'config remote.%s.pushurl %s' % (app.GIT_REMOTE, app.GIT_REMOTE_URL))
-                else:
-                    self._run_git(self._git_path, 'config remote.%s.pushurl %s'
-                                  % (app.GIT_REMOTE, app.GIT_REMOTE_URL.replace(app.GIT_ORG, app.GIT_USERNAME, 1)))
-        else:
-            if app.GIT_TOKEN:
-                if app.DEVELOPER:
-                    self._run_git(self._git_path, 'config remote.%s.pushurl %s' % (app.GIT_REMOTE, app.GIT_REMOTE_URL))
-                else:
-                    self._run_git(self._git_path, 'config remote.%s.pushurl %s'
-                                  % (app.GIT_REMOTE, app.GIT_REMOTE_URL.replace(app.GIT_ORG, app.GIT_USERNAME, 1)))
+        self._run_git(self._git_path, 'config remote.%s.pushurl %s' % (app.GIT_REMOTE, app.GIT_REMOTE_URL))
 
 
 class SourceUpdateManager(UpdateManager):


Test patch: