Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
Make possible to have STATIC_ROOT outside git repository
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface authored and Rémy HUBSCHER committed Feb 15, 2017
1 parent c7da81d commit c325629
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions jingo_minify/management/commands/compress_assets.py
Expand Up @@ -36,21 +36,20 @@ class Command(BaseCommand): # pragma: no cover
ext_media_path = os.path.join(get_media_root(), 'external')

def update_hashes(self, update=False):
def media_git_id(media_path):
git_bin = getattr(settings, 'GIT_BIN', 'git')
id = check_output([git_bin, "-C", path(media_path),
"rev-parse", "--short", "HEAD"]).strip()
if update:
# Adds a time based hash on to the build id.
return '%s-%s' % (id, hex(int(time.time()))[2:])
return id
path = getattr(settings, 'JINGO_MINIFY_ASSETS_GIT_ROOT', '.')
git_bin = getattr(settings, 'GIT_BIN', 'git')
id = check_output([git_bin, "-C", path,
"rev-parse", "--short", "HEAD"]).strip()
if update:
# Adds a time based hash on to the build id.
id = '%s-%s' % (id, hex(int(time.time()))[2:])

build_id_file = os.path.realpath(os.path.join(settings.ROOT,
'build.py'))
with open(build_id_file, 'w') as f:
f.write('BUILD_ID_CSS = "%s"\n' % media_git_id('css'))
f.write('BUILD_ID_JS = "%s"\n' % media_git_id('js'))
f.write('BUILD_ID_IMG = "%s"\n' % media_git_id('img'))
f.write('BUILD_ID_CSS = "%s"\n' % id)
f.write('BUILD_ID_JS = "%s"\n' % id)
f.write('BUILD_ID_IMG = "%s"\n' % id)
f.write('BUNDLE_HASHES = %s\n' % self.bundle_hashes)

def handle(self, **options):
Expand All @@ -59,7 +58,7 @@ def handle(self, **options):
return

jar_path = (os.path.dirname(__file__), '..', '..', 'bin',
'yuicompressor-2.4.7.jar')
'yuicompressor-2.4.7.jar')
self.path_to_jar = os.path.realpath(os.path.join(*jar_path))

self.v = '-v' if options.get('verbosity', False) == '2' else ''
Expand Down

0 comments on commit c325629

Please sign in to comment.