Repository: Cog-Creators/Red-DiscordBot

Issue:
[Downloader] Sporadic issue with [p]cog update
```
Traceback (most recent call last):
  File "lib\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(args, **kwargs)
  File "C:\Users\bot\Downloads\X\cogs\downloader.py", line 243, in update
    name, updates, oldhash = await f
  File "C:\Users\bot\AppData\Local\Programs\Python\Python36\lib\asyncio\tasks.py", line 452, in _wait_for_one
    return f.result()  # May raise f.exception().
  File "C:\Users\bot\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\thread.py", line 55, in run
    result = self.fn(self.args, **self.kwargs)
  File "C:\Users\bot\Downloads\X\cogs\downloader.py", line 615, in update_repo
    status, cogpath = f.split('\t')
ValueError: too many values to unpack (expected 2)
```

Reported by a user. Seems to cease after a restart.


Discussion:

Resolving patch:
diff --git a/cogs/downloader.py b/cogs/downloader.py
--- a/cogs/downloader.py
+++ b/cogs/downloader.py
@@ -4,7 +4,7 @@
 from cogs.utils.chat_formatting import pagify, box
 from __main__ import send_cmd_help, set_cog
 import os
-from subprocess import run, PIPE
+from subprocess import run as sp_run, PIPE
 import shutil
 from asyncio import as_completed
 from setuptools import distutils
@@ -351,7 +351,7 @@ def patch_notes_handler(self, repo_cog_hash_pairs):
                    "--reverse", oldhash + '..', cogfile
                    ]
             try:
-                log = run(cmd, stdout=PIPE).stdout.decode().strip()
+                log = sp_run(cmd, stdout=PIPE).stdout.decode().strip()
                 yield self.format_patch(repo, cog, log)
             except:
                 pass
@@ -557,6 +557,13 @@ def populate_list(self, name):
                 del self.repos[name][cog]
 
     def update_repo(self, name):
+
+        def run(*args, **kwargs):
+            env = os.environ.copy()
+            env['GIT_TERMINAL_PROMPT'] = '0'
+            kwargs['env'] = env
+            return sp_run(*args, **kwargs)
+
         try:
             dd = self.path
             if name not in self.repos:
@@ -606,18 +613,24 @@ def update_repo(self, name):
                     cmd = ['git', '-C', dd + name, 'diff', '--no-commit-id',
                            '--name-status', oldhash, newhash]
                     p = run(cmd, stdout=PIPE)
+
                     if p.returncode != 0:
                         raise UpdateError("Error in git diff")
+
                     changed = p.stdout.strip().decode().split('\n')
+
                     for f in changed:
                         if not f.endswith('.py'):
                             continue
-                        status, cogpath = f.split('\t')
+
+                        status, _, cogpath = f.partition('\t')
                         cogname = os.path.split(cogpath)[-1][:-3]  # strip .py
                         if status not in ret:
                             ret[status] = []
                         ret[status].append(cogname)
+
                     return name, ret, oldhash
+
         except CloningError as e:
             raise CloningError(name, *e.args) from None
         except UpdateError as e:


Test patch: