|
20 | 20 | ),
|
21 | 21 | )
|
22 | 22 |
|
| 23 | +def _get_repo_basename(repo_parent_dir, repo): |
| 24 | + repo_basename = os.path.splitext(os.path.basename(repo))[0] |
| 25 | + local_repo_dir = os.path.join(repo_parent_dir, repo_basename) |
| 26 | + # For backward compatibility |
| 27 | + # restore .git extension |
| 28 | + # if a repo with that name exists |
| 29 | + if os.path.exists(local_repo_dir + ".git"): |
| 30 | + repo_basename += ".git" |
| 31 | + return repo_basename |
| 32 | + |
23 | 33 | class SyncHandler(JupyterHandler):
|
24 | 34 | def __init__(self, *args, **kwargs):
|
25 | 35 | super().__init__(*args, **kwargs)
|
@@ -78,8 +88,7 @@ async def get(self):
|
78 | 88 | # must be expanded.
|
79 | 89 | repo_parent_dir = os.path.join(os.path.expanduser(self.settings['server_root_dir']),
|
80 | 90 | os.getenv('NBGITPULLER_PARENTPATH', ''))
|
81 |
| - repo_basename = os.path.splitext(os.path.basename(repo))[0] |
82 |
| - repo_dir = os.path.join(repo_parent_dir, self.get_argument('targetpath', repo_basename)) |
| 91 | + repo_dir = os.path.join(repo_parent_dir, self.get_argument('targetpath', _get_repo_basename(repo_parent_dir, repo))) |
83 | 92 |
|
84 | 93 | # We gonna send out event streams!
|
85 | 94 | self.set_header('content-type', 'text/event-stream')
|
@@ -155,9 +164,10 @@ async def get(self):
|
155 | 164 | self.get_argument('subPath', '.')
|
156 | 165 | app = self.get_argument('app', app_env)
|
157 | 166 | parent_reldir = os.getenv('NBGITPULLER_PARENTPATH', '')
|
158 |
| - repo_basename = os.path.splitext(os.path.basename(repo))[0] |
| 167 | + repo_parent_dir = os.path.join(os.path.expanduser(self.settings['server_root_dir']), |
| 168 | + os.getenv('NBGITPULLER_PARENTPATH', '')) |
159 | 169 | targetpath = self.get_argument('targetpath', None) or \
|
160 |
| - self.get_argument('targetPath', repo_basename) |
| 170 | + self.get_argument('targetPath', _get_repo_basename(repo_parent_dir, repo)) |
161 | 171 |
|
162 | 172 | if urlPath:
|
163 | 173 | path = urlPath
|
|
0 commit comments