{"issue":{"created_at":"2011-12-04T01:21:07Z","state":"open","updated_at":"2011-12-04T01:24:01Z","comments":1,"user":{"gravatar_id":"d2b784cfcc2724a36f3a88ef2bbc4b07","id":183331,"url":"https://api.github.com/users/mbferg","avatar_url":"https://secure.gravatar.com/avatar/d2b784cfcc2724a36f3a88ef2bbc4b07?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mbferg"},"body":"Plain and simple, `os.path.commonprefix` is a misleading and broken function that needs to die.  Unfortunately, pipeline's `compressor.compressors.Compressor.compile_templates` function uses it to calculate base paths for templates.  Here's an example:\r\n\r\nLet's say I have a directory, `js/templates/mymodule` and in that directory I have two files, `form` and `field`.  In my `settings.py`:\r\n\r\n```python\r\nPIPELINE_JS = {\r\n    'mymodule': {\r\n        'source_filenames': (\r\n            'js/templates/mymodule/*.jst',\r\n        ),\r\n        'output_filename': 'js/mymodule-?.js'\r\n    }\r\n}\r\n```\r\n\r\nUsing `os.path.commonprefix` on these files would mean that compressor sets base_path as `js/templates/mymodule/f`, which isn't a path, just a substring.  This doesn't break anything until you look at the generated template code, and see `JST['ile']` and `JST['ield']`.  This problem isn't exclusive to file names, since `os.path.commonprefix` is actually path-agnostic.\r\n\r\nWhile the easiest way to fix this might be to eliminate dependency on `os.path.commonprefix`, it's probably better to offer an overall better solution for customizing names/prefixes for JavaScript Templates.  I'll see what I can come up with and possibly submit an experimental patch this week.\r\n\r\nhttps://github.com/cyberdelia/django-pipeline/blob/master/pipeline/compressors/__init__.py#L83","assignee":null,"number":48,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"id":2440181,"labels":[],"title":"Remove usage of os.path.commonprefix in pipeline.compressors.Compressor.compile_templates","html_url":"https://github.com/cyberdelia/django-pipeline/issues/48","closed_at":null,"url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/48","milestone":null},"action":"created","comment":{"created_at":"2011-12-04T01:24:01Z","updated_at":"2011-12-04T01:24:01Z","user":{"gravatar_id":"d2b784cfcc2724a36f3a88ef2bbc4b07","id":183331,"url":"https://api.github.com/users/mbferg","avatar_url":"https://secure.gravatar.com/avatar/d2b784cfcc2724a36f3a88ef2bbc4b07?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mbferg"},"body":"Possible alternatives to `os.path.commonprefix`: http://rosettacode.org/wiki/Find_Common_Directory_Path#Python","id":3004294,"url":"https://api.github.com/repos/cyberdelia/django-pipeline/issues/comments/3004294"}}