Add deploystatic commandline argument to provide githash
authorMagnus Hagander <magnus@hagander.net>
Sun, 23 Sep 2018 13:46:51 +0000 (15:46 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sun, 23 Sep 2018 13:46:51 +0000 (15:46 +0200)
This will be needed when deploying off a branch, where we cannot just
open a file.

tools/deploystatic/deploystatic.py

index 32d2d604ee122ea23a61dc1621eae3b0f92a9d68..f0a262dd274c6e7863d561762bfcaf8bb71e466c 100755 (executable)
@@ -240,6 +240,7 @@ if __name__ == "__main__":
        parser.add_argument('destpath', type=str, help='Destination path')
        parser.add_argument('--branch', type=str, help='Deploy directly from branch')
        parser.add_argument('--templates', action='store_true', help='Deploy templates (except pages) and static instead of pages')
+       parser.add_argument('--githash', type=str, help='Use hash as githash instead of autodetecting')
 
        args = parser.parse_args()
 
@@ -293,7 +294,10 @@ if __name__ == "__main__":
 
                # Generate a githash file
                with open(os.path.join(args.destpath, ".deploystatic_githash"), "w") as f:
-                       f.write(find_git_revision(args.sourcepath))
+                       if args.githash:
+                               f.write(args.githash)
+                       else:
+                               f.write(find_git_revision(args.sourcepath))
 
                sys.exit(0)
 
@@ -308,7 +312,10 @@ if __name__ == "__main__":
        context = load_context(source.readfile('templates/context.json'))
 
        # Fetch the current git revision if this is coming out of a git repository
-       context['githash'] = find_git_revision(args.sourcepath)
+       if args.githash:
+               context['githash'] = args.githash
+       else:
+               context['githash'] = find_git_revision(args.sourcepath)
 
        # Load a context that can override everything, including static hashes
        context.update(load_context(source.readfile('templates/context.override.json')))