When using deploystatic to deploy directly from a repository branch,
there is no git repository in the resulting template directory. This
means that when the directory is loaded from the main jinja parser, it
does not find a .git, and thus does not set a githash.
To make this work, have deploystatic drop a file called
.deploystatic_githash into the target directory, and have the jinja code
specifically look for this code when trying to find the githash.
with open(refname) as f:
fullref = f.readline()
return fullref[:7]
+ elif os.path.exists(os.path.join(path, ".deploystatic_githash")):
+ with open(os.path.join(path, ".deploystatic_githash")) as f:
+ return f.readline().strip()
+
# Else step up one level
path = os.path.dirname(path)
+ # If no direct git hash found, search for a deploystatic file
return None
if not f in knownfiles:
os.unlink(os.path.join(args.destpath, f))
+ # Generate a githash file
+ with open(os.path.join(args.destpath, ".deploystatic_githash"), "w") as f:
+ f.write(find_git_revision(args.sourcepath))
+
sys.exit(0)
# Set up jinja environment