From b8a076b79834b7ec3c708cbd45ebf10624b1230f Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Mon, 12 Aug 2024 17:58:28 -0700 Subject: [PATCH] Handle extra trailing slash when determining default targetpath Otherwise we end up with targetpath being `.`, which always exists (given it is current working directory) and we end up with weird failures Discovered while working on https://github.com/2i2c-org/infrastructure/issues/4576 --- nbgitpuller/handlers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nbgitpuller/handlers.py b/nbgitpuller/handlers.py index 3cd4c35..d170d1c 100644 --- a/nbgitpuller/handlers.py +++ b/nbgitpuller/handlers.py @@ -154,8 +154,11 @@ async def get(self): self.get_argument('subPath', '.') app = self.get_argument('app', app_env) parent_reldir = os.getenv('NBGITPULLER_PARENTPATH', '') + # Remove trailing slashes before determining default targetPath + # Otherwise we end up with targetpath being `.`, which always exists (given it is current + # working directory) and we end up with weird failures targetpath = self.get_argument('targetpath', None) or \ - self.get_argument('targetPath', repo.split('/')[-1]) + self.get_argument('targetPath', repo.rstrip('/').split('/')[-1]) if urlPath: path = urlPath