#!/usr/bin/env python3 # Copyright 2021 Codethink Limited # raw file archive using git-lfs frontend for git-fast-import import hashlib import os import shutil import subprocess import sys import time branch_name = "master" branch_ref = "refs/heads/%s" % branch_name committer_name = "Lorry Raw File Importer" committer_email = "lorry-raw-file-importer@lorry" def commit_lfs_gitattributes(fast_import): commit_time = int(time.time()) commit = ( "commit {ref}\n" "committer {committer_name} <{committer_email}> {commit_time} +0000\n" "data < {commit_time} +0000\n" "data <", "") sys.exit(1) raw_file = sys.argv[1] relpath = sys.argv[2] last_commit = get_last_commit() with subprocess.Popen( "git fast-import --quiet", shell=True, stdin=subprocess.PIPE ) as import_proc: if not last_commit: commit_lfs_gitattributes(import_proc.stdin) commit_lfs_file(raw_file, relpath, last_commit, import_proc.stdin) import_proc.stdin.close() if import_proc.wait() != 0: sys.exit(1) main()