We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Replace ghp-import2 by ghp-import?
c.f. comments by author of ghp-import2 @ionelmc from https://github.com/conda-forge/staged-recipes/pull/13605#issuecomment-757556835

> Hello everyone, ghp-import2 is basically ghp-import + proper packaging and a couple integration tests. Looks like ghp-import is maintained as of last year and has some bugfixes and the prefix option (packaging and testing is still trash tho). I don't really want to maintain ghp-import2 - I just made it cause ghp-import was dead and horrendously broken packaging-wise 4 years ago.

Edit: links:

* [ghp-import](https://github.com/c-w/ghp-import)
* [ghp-import2](https://github.com/ionelmc/python-ghp-import)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nikola/plugins/command/github_deploy.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Copyright © 2014-2021 Puneeth Chaganti and others.
4 
5 # Permission is hereby granted, free of charge, to any
6 # person obtaining a copy of this software and associated
7 # documentation files (the "Software"), to deal in the
8 # Software without restriction, including without limitation
9 # the rights to use, copy, modify, merge, publish,
10 # distribute, sublicense, and/or sell copies of the
11 # Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
13 #
14 # The above copyright notice and this permission notice
15 # shall be included in all copies or substantial portions of
16 # the Software.
17 #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
22 # OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 
27 """Deploy site to GitHub Pages."""
28 
29 import os
30 import subprocess
31 from textwrap import dedent
32 
33 from nikola.plugin_categories import Command
34 from nikola.plugins.command.check import real_scan_files
35 from nikola.utils import req_missing, clean_before_deployment
36 from nikola.__main__ import main
37 from nikola import __version__
38 
39 
40 def uni_check_output(*args, **kwargs):
41     """Run command and return output as Unicode (UTf-8)."""
42     o = subprocess.check_output(*args, **kwargs)
43     return o.decode('utf-8')
44 
45 
46 def check_ghp_import_installed():
47     """Check if ghp-import is installed."""
48     try:
49         subprocess.check_output(['ghp-import', '-h'])
50     except OSError:
51         # req_missing defaults to `python=True` — and it’s meant to be like this.
52         # `ghp-import` is installed via pip, but the only way to use it is by executing the script it installs.
53         req_missing(['ghp-import2'], 'deploy the site to GitHub Pages')
54 
55 
56 class DeployFailedException(Exception):
57     """An internal exception for deployment errors."""
58 
59     pass
60 
61 
62 class CommandGitHubDeploy(Command):
63     """Deploy site to GitHub Pages."""
64 
65     name = 'github_deploy'
66 
67     doc_usage = '[-m COMMIT_MESSAGE]'
68     doc_purpose = 'deploy the site to GitHub Pages'
69     doc_description = dedent(
70         """\
71         This command can be used to deploy your site to GitHub Pages. It uses ghp-import to do this task. It also optionally commits to the source branch.
72 
73         Configuration help: https://getnikola.com/handbook.html#deploying-to-github"""
74     )
75     cmd_options = [
76         {
77             'name': 'commit_message',
78             'short': 'm',
79             'long': 'message',
80             'default': 'Nikola auto commit.',
81             'type': str,
82             'help': 'Commit message',
83         },
84     ]
85 
86     def _execute(self, options, args):
87         """Run the deployment."""
88         # Check if ghp-import is installed
89         check_ghp_import_installed()
90 
91         # Build before deploying
92         build = main(['build'])
93         if build != 0:
94             self.logger.error('Build failed, not deploying to GitHub')
95             return build
96 
97         # Clean non-target files
98         only_on_output, _ = real_scan_files(self.site)
99         for f in only_on_output:
100             os.unlink(f)
101 
102         # Remove drafts and future posts if requested (Issue #2406)
103         undeployed_posts = clean_before_deployment(self.site)
104         if undeployed_posts:
105             self.logger.warning("Deleted {0} posts due to DEPLOY_* settings".format(len(undeployed_posts)))
106 
107         # Commit and push
108         return self._commit_and_push(options['commit_message'])
109 
110     def _run_command(self, command, xfail=False):
111         """Run a command that may or may not fail."""
112         self.logger.info("==> {0}".format(command))
113         try:
114             subprocess.check_call(command)
115             return 0
116         except subprocess.CalledProcessError as e:
117             if xfail:
118                 return e.returncode
119             self.logger.error(
120                 'Failed GitHub deployment -- command {0} '
121                 'returned {1}'.format(e.cmd, e.returncode)
122             )
123             raise DeployFailedException(e.returncode)
124 
125     def _commit_and_push(self, commit_first_line):
126         """Commit all the files and push."""
127         source = self.site.config['GITHUB_SOURCE_BRANCH']
128         deploy = self.site.config['GITHUB_DEPLOY_BRANCH']
129         remote = self.site.config['GITHUB_REMOTE_NAME']
130         autocommit = self.site.config['GITHUB_COMMIT_SOURCE']
131         try:
132             if autocommit:
133                 commit_message = (
134                     '{0}\n\n'
135                     'Nikola version: {1}'.format(commit_first_line, __version__)
136                 )
137                 e = self._run_command(['git', 'checkout', source], True)
138                 if e != 0:
139                     self._run_command(['git', 'checkout', '-b', source])
140                 self._run_command(['git', 'add', '.'])
141                 # Figure out if there is anything to commit
142                 e = self._run_command(['git', 'diff-index', '--quiet', 'HEAD'], True)
143                 if e != 0:
144                     self._run_command(['git', 'commit', '-am', commit_message])
145                 else:
146                     self.logger.info('Nothing to commit to source branch.')
147 
148             try:
149                 source_commit = uni_check_output(['git', 'rev-parse', source])
150             except subprocess.CalledProcessError:
151                 try:
152                     source_commit = uni_check_output(['git', 'rev-parse', 'HEAD'])
153                 except subprocess.CalledProcessError:
154                     source_commit = '?'
155 
156             commit_message = (
157                 '{0}\n\n'
158                 'Source commit: {1}'
159                 'Nikola version: {2}'.format(commit_first_line, source_commit, __version__)
160             )
161             output_folder = self.site.config['OUTPUT_FOLDER']
162 
163             command = ['ghp-import', '-n', '-m', commit_message, '-p', '-r', remote, '-b', deploy, output_folder]
164 
165             self._run_command(command)
166 
167             if autocommit:
168                 self._run_command(['git', 'push', '-u', remote, source])
169         except DeployFailedException as e:
170             return e.args[0]
171 
172         self.logger.info("Successful deployment")
173
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nikola/plugins/command/github_deploy.py b/nikola/plugins/command/github_deploy.py
--- a/nikola/plugins/command/github_deploy.py
+++ b/nikola/plugins/command/github_deploy.py
@@ -50,7 +50,7 @@
     except OSError:
         # req_missing defaults to `python=True` — and it’s meant to be like this.
         # `ghp-import` is installed via pip, but the only way to use it is by executing the script it installs.
-        req_missing(['ghp-import2'], 'deploy the site to GitHub Pages')
+        req_missing(['ghp-import'], 'deploy the site to GitHub Pages')
 
 
 class DeployFailedException(Exception):

{"golden_diff": "diff --git a/nikola/plugins/command/github_deploy.py b/nikola/plugins/command/github_deploy.py\n--- a/nikola/plugins/command/github_deploy.py\n+++ b/nikola/plugins/command/github_deploy.py\n@@ -50,7 +50,7 @@\n     except OSError:\n         # req_missing defaults to `python=True` \u2014 and it\u2019s meant to be like this.\n         # `ghp-import` is installed via pip, but the only way to use it is by executing the script it installs.\n-        req_missing(['ghp-import2'], 'deploy the site to GitHub Pages')\n+        req_missing(['ghp-import'], 'deploy the site to GitHub Pages')\n \n \n class DeployFailedException(Exception):\n", "issue": "Replace ghp-import2 by ghp-import?\nc.f. comments by author of ghp-import2 @ionelmc from https://github.com/conda-forge/staged-recipes/pull/13605#issuecomment-757556835\r\n\r\n> Hello everyone, ghp-import2 is basically ghp-import + proper packaging and a couple integration tests. Looks like ghp-import is maintained as of last year and has some bugfixes and the prefix option (packaging and testing is still trash tho). I don't really want to maintain ghp-import2 - I just made it cause ghp-import was dead and horrendously broken packaging-wise 4 years ago.\r\n\r\nEdit: links:\r\n\r\n* [ghp-import](https://github.com/c-w/ghp-import)\r\n* [ghp-import2](https://github.com/ionelmc/python-ghp-import)\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2014-2021 Puneeth Chaganti and others.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\"\"\"Deploy site to GitHub Pages.\"\"\"\n\nimport os\nimport subprocess\nfrom textwrap import dedent\n\nfrom nikola.plugin_categories import Command\nfrom nikola.plugins.command.check import real_scan_files\nfrom nikola.utils import req_missing, clean_before_deployment\nfrom nikola.__main__ import main\nfrom nikola import __version__\n\n\ndef uni_check_output(*args, **kwargs):\n    \"\"\"Run command and return output as Unicode (UTf-8).\"\"\"\n    o = subprocess.check_output(*args, **kwargs)\n    return o.decode('utf-8')\n\n\ndef check_ghp_import_installed():\n    \"\"\"Check if ghp-import is installed.\"\"\"\n    try:\n        subprocess.check_output(['ghp-import', '-h'])\n    except OSError:\n        # req_missing defaults to `python=True` \u2014 and it\u2019s meant to be like this.\n        # `ghp-import` is installed via pip, but the only way to use it is by executing the script it installs.\n        req_missing(['ghp-import2'], 'deploy the site to GitHub Pages')\n\n\nclass DeployFailedException(Exception):\n    \"\"\"An internal exception for deployment errors.\"\"\"\n\n    pass\n\n\nclass CommandGitHubDeploy(Command):\n    \"\"\"Deploy site to GitHub Pages.\"\"\"\n\n    name = 'github_deploy'\n\n    doc_usage = '[-m COMMIT_MESSAGE]'\n    doc_purpose = 'deploy the site to GitHub Pages'\n    doc_description = dedent(\n        \"\"\"\\\n        This command can be used to deploy your site to GitHub Pages. It uses ghp-import to do this task. It also optionally commits to the source branch.\n\n        Configuration help: https://getnikola.com/handbook.html#deploying-to-github\"\"\"\n    )\n    cmd_options = [\n        {\n            'name': 'commit_message',\n            'short': 'm',\n            'long': 'message',\n            'default': 'Nikola auto commit.',\n            'type': str,\n            'help': 'Commit message',\n        },\n    ]\n\n    def _execute(self, options, args):\n        \"\"\"Run the deployment.\"\"\"\n        # Check if ghp-import is installed\n        check_ghp_import_installed()\n\n        # Build before deploying\n        build = main(['build'])\n        if build != 0:\n            self.logger.error('Build failed, not deploying to GitHub')\n            return build\n\n        # Clean non-target files\n        only_on_output, _ = real_scan_files(self.site)\n        for f in only_on_output:\n            os.unlink(f)\n\n        # Remove drafts and future posts if requested (Issue #2406)\n        undeployed_posts = clean_before_deployment(self.site)\n        if undeployed_posts:\n            self.logger.warning(\"Deleted {0} posts due to DEPLOY_* settings\".format(len(undeployed_posts)))\n\n        # Commit and push\n        return self._commit_and_push(options['commit_message'])\n\n    def _run_command(self, command, xfail=False):\n        \"\"\"Run a command that may or may not fail.\"\"\"\n        self.logger.info(\"==> {0}\".format(command))\n        try:\n            subprocess.check_call(command)\n            return 0\n        except subprocess.CalledProcessError as e:\n            if xfail:\n                return e.returncode\n            self.logger.error(\n                'Failed GitHub deployment -- command {0} '\n                'returned {1}'.format(e.cmd, e.returncode)\n            )\n            raise DeployFailedException(e.returncode)\n\n    def _commit_and_push(self, commit_first_line):\n        \"\"\"Commit all the files and push.\"\"\"\n        source = self.site.config['GITHUB_SOURCE_BRANCH']\n        deploy = self.site.config['GITHUB_DEPLOY_BRANCH']\n        remote = self.site.config['GITHUB_REMOTE_NAME']\n        autocommit = self.site.config['GITHUB_COMMIT_SOURCE']\n        try:\n            if autocommit:\n                commit_message = (\n                    '{0}\\n\\n'\n                    'Nikola version: {1}'.format(commit_first_line, __version__)\n                )\n                e = self._run_command(['git', 'checkout', source], True)\n                if e != 0:\n                    self._run_command(['git', 'checkout', '-b', source])\n                self._run_command(['git', 'add', '.'])\n                # Figure out if there is anything to commit\n                e = self._run_command(['git', 'diff-index', '--quiet', 'HEAD'], True)\n                if e != 0:\n                    self._run_command(['git', 'commit', '-am', commit_message])\n                else:\n                    self.logger.info('Nothing to commit to source branch.')\n\n            try:\n                source_commit = uni_check_output(['git', 'rev-parse', source])\n            except subprocess.CalledProcessError:\n                try:\n                    source_commit = uni_check_output(['git', 'rev-parse', 'HEAD'])\n                except subprocess.CalledProcessError:\n                    source_commit = '?'\n\n            commit_message = (\n                '{0}\\n\\n'\n                'Source commit: {1}'\n                'Nikola version: {2}'.format(commit_first_line, source_commit, __version__)\n            )\n            output_folder = self.site.config['OUTPUT_FOLDER']\n\n            command = ['ghp-import', '-n', '-m', commit_message, '-p', '-r', remote, '-b', deploy, output_folder]\n\n            self._run_command(command)\n\n            if autocommit:\n                self._run_command(['git', 'push', '-u', remote, source])\n        except DeployFailedException as e:\n            return e.args[0]\n\n        self.logger.info(\"Successful deployment\")\n", "path": "nikola/plugins/command/github_deploy.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2014-2021 Puneeth Chaganti and others.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\"\"\"Deploy site to GitHub Pages.\"\"\"\n\nimport os\nimport subprocess\nfrom textwrap import dedent\n\nfrom nikola.plugin_categories import Command\nfrom nikola.plugins.command.check import real_scan_files\nfrom nikola.utils import req_missing, clean_before_deployment\nfrom nikola.__main__ import main\nfrom nikola import __version__\n\n\ndef uni_check_output(*args, **kwargs):\n    \"\"\"Run command and return output as Unicode (UTf-8).\"\"\"\n    o = subprocess.check_output(*args, **kwargs)\n    return o.decode('utf-8')\n\n\ndef check_ghp_import_installed():\n    \"\"\"Check if ghp-import is installed.\"\"\"\n    try:\n        subprocess.check_output(['ghp-import', '-h'])\n    except OSError:\n        # req_missing defaults to `python=True` \u2014 and it\u2019s meant to be like this.\n        # `ghp-import` is installed via pip, but the only way to use it is by executing the script it installs.\n        req_missing(['ghp-import'], 'deploy the site to GitHub Pages')\n\n\nclass DeployFailedException(Exception):\n    \"\"\"An internal exception for deployment errors.\"\"\"\n\n    pass\n\n\nclass CommandGitHubDeploy(Command):\n    \"\"\"Deploy site to GitHub Pages.\"\"\"\n\n    name = 'github_deploy'\n\n    doc_usage = '[-m COMMIT_MESSAGE]'\n    doc_purpose = 'deploy the site to GitHub Pages'\n    doc_description = dedent(\n        \"\"\"\\\n        This command can be used to deploy your site to GitHub Pages. It uses ghp-import to do this task. It also optionally commits to the source branch.\n\n        Configuration help: https://getnikola.com/handbook.html#deploying-to-github\"\"\"\n    )\n    cmd_options = [\n        {\n            'name': 'commit_message',\n            'short': 'm',\n            'long': 'message',\n            'default': 'Nikola auto commit.',\n            'type': str,\n            'help': 'Commit message',\n        },\n    ]\n\n    def _execute(self, options, args):\n        \"\"\"Run the deployment.\"\"\"\n        # Check if ghp-import is installed\n        check_ghp_import_installed()\n\n        # Build before deploying\n        build = main(['build'])\n        if build != 0:\n            self.logger.error('Build failed, not deploying to GitHub')\n            return build\n\n        # Clean non-target files\n        only_on_output, _ = real_scan_files(self.site)\n        for f in only_on_output:\n            os.unlink(f)\n\n        # Remove drafts and future posts if requested (Issue #2406)\n        undeployed_posts = clean_before_deployment(self.site)\n        if undeployed_posts:\n            self.logger.warning(\"Deleted {0} posts due to DEPLOY_* settings\".format(len(undeployed_posts)))\n\n        # Commit and push\n        return self._commit_and_push(options['commit_message'])\n\n    def _run_command(self, command, xfail=False):\n        \"\"\"Run a command that may or may not fail.\"\"\"\n        self.logger.info(\"==> {0}\".format(command))\n        try:\n            subprocess.check_call(command)\n            return 0\n        except subprocess.CalledProcessError as e:\n            if xfail:\n                return e.returncode\n            self.logger.error(\n                'Failed GitHub deployment -- command {0} '\n                'returned {1}'.format(e.cmd, e.returncode)\n            )\n            raise DeployFailedException(e.returncode)\n\n    def _commit_and_push(self, commit_first_line):\n        \"\"\"Commit all the files and push.\"\"\"\n        source = self.site.config['GITHUB_SOURCE_BRANCH']\n        deploy = self.site.config['GITHUB_DEPLOY_BRANCH']\n        remote = self.site.config['GITHUB_REMOTE_NAME']\n        autocommit = self.site.config['GITHUB_COMMIT_SOURCE']\n        try:\n            if autocommit:\n                commit_message = (\n                    '{0}\\n\\n'\n                    'Nikola version: {1}'.format(commit_first_line, __version__)\n                )\n                e = self._run_command(['git', 'checkout', source], True)\n                if e != 0:\n                    self._run_command(['git', 'checkout', '-b', source])\n                self._run_command(['git', 'add', '.'])\n                # Figure out if there is anything to commit\n                e = self._run_command(['git', 'diff-index', '--quiet', 'HEAD'], True)\n                if e != 0:\n                    self._run_command(['git', 'commit', '-am', commit_message])\n                else:\n                    self.logger.info('Nothing to commit to source branch.')\n\n            try:\n                source_commit = uni_check_output(['git', 'rev-parse', source])\n            except subprocess.CalledProcessError:\n                try:\n                    source_commit = uni_check_output(['git', 'rev-parse', 'HEAD'])\n                except subprocess.CalledProcessError:\n                    source_commit = '?'\n\n            commit_message = (\n                '{0}\\n\\n'\n                'Source commit: {1}'\n                'Nikola version: {2}'.format(commit_first_line, source_commit, __version__)\n            )\n            output_folder = self.site.config['OUTPUT_FOLDER']\n\n            command = ['ghp-import', '-n', '-m', commit_message, '-p', '-r', remote, '-b', deploy, output_folder]\n\n            self._run_command(command)\n\n            if autocommit:\n                self._run_command(['git', 'push', '-u', remote, source])\n        except DeployFailedException as e:\n            return e.args[0]\n\n        self.logger.info(\"Successful deployment\")\n", "path": "nikola/plugins/command/github_deploy.py"}]}