prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  buildbot-2.6.0.gitarchive.tar.gz is not generated correctly
  ```
  <rjarry> tardyp: the .gitarchive.tar.gz file of release 2.6.0 is corrupted
  16:57:31 <rjarry> buildbot-v2.5.1.gitarchive.tar.gz
  16:57:31 <rjarry> 4.69 MB
  16:57:31 <rjarry> buildbot-v2.5.1.gitarchive.tar.gz.sig
  16:57:31 <rjarry> 310 Bytes
  16:57:47 <rjarry> last one does not
  16:57:49 <rjarry> buildbot-2.6.0.gitarchive.tar.gz
  16:57:49 <rjarry> 15 Bytes
  16:57:49 <rjarry> buildbot-2.6.0.gitarchive.tar.gz.sig
  16:57:49 <rjarry> 310 Bytes
  ```
  We shall regenerate the archive and signature manually.
  preferably @p12tic , which originaly signed the rest of the release
  
  This archive is used by debian packaging as they require to build everything from source
  
  </issue>
  <code>
  [start of common/download_release.py]
  1 #!/usr/bin/env python3
  2 
  3 import os
  4 
  5 import requests
  6 import yaml
  7 
  8 
  9 def download(url, fn):
  10     print(url, fn)
  11     if os.path.exists(fn):
  12         return
  13     with open(fn, 'wb') as f:
  14         r = s.get(url, stream=True)
  15         for c in r.iter_content(1024):
  16             f.write(c)
  17 
  18 
  19 def main():
  20     global s
  21     with open(os.path.expanduser("~/.config/hub")) as f:
  22         conf = yaml.safe_load(f)
  23         token = conf['github.com'][0]['oauth_token']
  24 
  25     s = requests.Session()
  26     s.headers.update({'Authorization': 'token ' + token})
  27     r = s.get("https://api.github.com/repos/buildbot/buildbot/releases/latest")
  28     r.raise_for_status()
  29     r = r.json()
  30     tag = r['name']
  31     upload_url = r['upload_url'].split('{')[0]
  32     assets = s.get("https://api.github.com/repos/buildbot/buildbot/releases/{id}/assets".format(id=r['id']))
  33     assets.raise_for_status()
  34     assets = assets.json()
  35     os.system("mkdir -p dist")
  36     for url in (a['browser_download_url'] for a in assets):
  37         if url.endswith(".whl") or url.endswith(".tar.gz"):
  38             fn = os.path.join('dist', url.split('/')[-1])
  39             download(url, fn)
  40     # download tag archive
  41     url = "https://github.com/buildbot/buildbot/archive/{tag}.tar.gz".format(tag=tag)
  42     fn = os.path.join('dist', "buildbot-{tag}.gitarchive.tar.gz".format(tag=tag))
  43     download(url, fn)
  44     sigfn = fn + ".sig"
  45     if os.path.exists(sigfn):
  46         os.unlink(sigfn)
  47     # sign the tag archive for debian
  48     os.system("gpg --output {} -b {}".format(sigfn, fn))
  49     sigfnbase = os.path.basename(sigfn)
  50     r = s.post(upload_url,
  51                headers={'Content-Type': "application/pgp-signature"},
  52                params={"name": sigfnbase},
  53                data=open(sigfn, 'rb'))
  54     print(r.content)
  55     fnbase = os.path.basename(fn)
  56     r = s.post(upload_url,
  57                headers={'Content-Type': "application/gzip"},
  58                params={"name": fnbase},
  59                data=open(fn, 'rb'))
  60     print(r.content)
  61     # remove files so that twine upload do not upload them
  62     os.unlink(sigfn)
  63     os.unlink(fn)
  64 
  65 
  66 if __name__ == '__main__':
  67     main()
  68
  [end of common/download_release.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/common/download_release.py b/common/download_release.py
  --- a/common/download_release.py
  +++ b/common/download_release.py
  @@ -6,18 +6,19 @@
   import yaml
   
   
  -def download(url, fn):
  -    print(url, fn)
  +def download(session, url, fn):
       if os.path.exists(fn):
  -        return
  +        print('Removing old file {}'.format(fn))
  +        os.unlink(fn)
  +    print('Downloading {} from {}'.format(fn, url))
       with open(fn, 'wb') as f:
  -        r = s.get(url, stream=True)
  +        r = session.get(url, stream=True)
  +        r.raise_for_status()
           for c in r.iter_content(1024):
               f.write(c)
   
   
   def main():
  -    global s
       with open(os.path.expanduser("~/.config/hub")) as f:
           conf = yaml.safe_load(f)
           token = conf['github.com'][0]['oauth_token']
  @@ -32,15 +33,15 @@
       assets = s.get("https://api.github.com/repos/buildbot/buildbot/releases/{id}/assets".format(id=r['id']))
       assets.raise_for_status()
       assets = assets.json()
  -    os.system("mkdir -p dist")
  +    os.makedirs('dist', exist_ok=True)
       for url in (a['browser_download_url'] for a in assets):
           if url.endswith(".whl") or url.endswith(".tar.gz"):
               fn = os.path.join('dist', url.split('/')[-1])
  -            download(url, fn)
  +            download(s, url, fn)
       # download tag archive
       url = "https://github.com/buildbot/buildbot/archive/{tag}.tar.gz".format(tag=tag)
       fn = os.path.join('dist', "buildbot-{tag}.gitarchive.tar.gz".format(tag=tag))
  -    download(url, fn)
  +    download(s, url, fn)
       sigfn = fn + ".sig"
       if os.path.exists(sigfn):
           os.unlink(sigfn)
  
verification_info: {"golden_diff": "diff --git a/common/download_release.py b/common/download_release.py\n--- a/common/download_release.py\n+++ b/common/download_release.py\n@@ -6,18 +6,19 @@\n import yaml\n \n \n-def download(url, fn):\n-    print(url, fn)\n+def download(session, url, fn):\n     if os.path.exists(fn):\n-        return\n+        print('Removing old file {}'.format(fn))\n+        os.unlink(fn)\n+    print('Downloading {} from {}'.format(fn, url))\n     with open(fn, 'wb') as f:\n-        r = s.get(url, stream=True)\n+        r = session.get(url, stream=True)\n+        r.raise_for_status()\n         for c in r.iter_content(1024):\n             f.write(c)\n \n \n def main():\n-    global s\n     with open(os.path.expanduser(\"~/.config/hub\")) as f:\n         conf = yaml.safe_load(f)\n         token = conf['github.com'][0]['oauth_token']\n@@ -32,15 +33,15 @@\n     assets = s.get(\"https://api.github.com/repos/buildbot/buildbot/releases/{id}/assets\".format(id=r['id']))\n     assets.raise_for_status()\n     assets = assets.json()\n-    os.system(\"mkdir -p dist\")\n+    os.makedirs('dist', exist_ok=True)\n     for url in (a['browser_download_url'] for a in assets):\n         if url.endswith(\".whl\") or url.endswith(\".tar.gz\"):\n             fn = os.path.join('dist', url.split('/')[-1])\n-            download(url, fn)\n+            download(s, url, fn)\n     # download tag archive\n     url = \"https://github.com/buildbot/buildbot/archive/{tag}.tar.gz\".format(tag=tag)\n     fn = os.path.join('dist', \"buildbot-{tag}.gitarchive.tar.gz\".format(tag=tag))\n-    download(url, fn)\n+    download(s, url, fn)\n     sigfn = fn + \".sig\"\n     if os.path.exists(sigfn):\n         os.unlink(sigfn)\n", "issue": "buildbot-2.6.0.gitarchive.tar.gz is not generated correctly\n```\r\n<rjarry> tardyp: the .gitarchive.tar.gz file of release 2.6.0 is corrupted\r\n16:57:31 <rjarry> buildbot-v2.5.1.gitarchive.tar.gz\r\n16:57:31 <rjarry> 4.69 MB\r\n16:57:31 <rjarry> buildbot-v2.5.1.gitarchive.tar.gz.sig\r\n16:57:31 <rjarry> 310 Bytes\r\n16:57:47 <rjarry> last one does not\r\n16:57:49 <rjarry> buildbot-2.6.0.gitarchive.tar.gz\r\n16:57:49 <rjarry> 15 Bytes\r\n16:57:49 <rjarry> buildbot-2.6.0.gitarchive.tar.gz.sig\r\n16:57:49 <rjarry> 310 Bytes\r\n```\r\nWe shall regenerate the archive and signature manually.\r\npreferably @p12tic , which originaly signed the rest of the release\r\n\r\nThis archive is used by debian packaging as they require to build everything from source\n", "before_files": [{"content": "#!/usr/bin/env python3\n\nimport os\n\nimport requests\nimport yaml\n\n\ndef download(url, fn):\n    print(url, fn)\n    if os.path.exists(fn):\n        return\n    with open(fn, 'wb') as f:\n        r = s.get(url, stream=True)\n        for c in r.iter_content(1024):\n            f.write(c)\n\n\ndef main():\n    global s\n    with open(os.path.expanduser(\"~/.config/hub\")) as f:\n        conf = yaml.safe_load(f)\n        token = conf['github.com'][0]['oauth_token']\n\n    s = requests.Session()\n    s.headers.update({'Authorization': 'token ' + token})\n    r = s.get(\"https://api.github.com/repos/buildbot/buildbot/releases/latest\")\n    r.raise_for_status()\n    r = r.json()\n    tag = r['name']\n    upload_url = r['upload_url'].split('{')[0]\n    assets = s.get(\"https://api.github.com/repos/buildbot/buildbot/releases/{id}/assets\".format(id=r['id']))\n    assets.raise_for_status()\n    assets = assets.json()\n    os.system(\"mkdir -p dist\")\n    for url in (a['browser_download_url'] for a in assets):\n        if url.endswith(\".whl\") or url.endswith(\".tar.gz\"):\n            fn = os.path.join('dist', url.split('/')[-1])\n            download(url, fn)\n    # download tag archive\n    url = \"https://github.com/buildbot/buildbot/archive/{tag}.tar.gz\".format(tag=tag)\n    fn = os.path.join('dist', \"buildbot-{tag}.gitarchive.tar.gz\".format(tag=tag))\n    download(url, fn)\n    sigfn = fn + \".sig\"\n    if os.path.exists(sigfn):\n        os.unlink(sigfn)\n    # sign the tag archive for debian\n    os.system(\"gpg --output {} -b {}\".format(sigfn, fn))\n    sigfnbase = os.path.basename(sigfn)\n    r = s.post(upload_url,\n               headers={'Content-Type': \"application/pgp-signature\"},\n               params={\"name\": sigfnbase},\n               data=open(sigfn, 'rb'))\n    print(r.content)\n    fnbase = os.path.basename(fn)\n    r = s.post(upload_url,\n               headers={'Content-Type': \"application/gzip\"},\n               params={\"name\": fnbase},\n               data=open(fn, 'rb'))\n    print(r.content)\n    # remove files so that twine upload do not upload them\n    os.unlink(sigfn)\n    os.unlink(fn)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "common/download_release.py"}]}