#!/usr/bin/python3 # Copyright (C) 2018-2019 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import os import subprocess import sys sha1 = sys.argv[1] repo_path = os.environ['OLDPWD'] submodule_path = os.getcwd() submodule = os.path.relpath(submodule_path, repo_path) evtag = subprocess.check_output(['git-evtag-compute-py', sha1]) \ .decode('ascii') \ .split('\n') assert evtag[0].startswith('# git-evtag comment: ') assert evtag[1].startswith('Git-EVTag-v0-SHA512: ') os.chdir(repo_path) log = subprocess.check_output(['git', 'log', '-1', '--', submodule]) \ .decode('ascii') found_comment = False found_evtag = False for line in log.split('\n'): if evtag[0] in line: found_comment = True elif evtag[1] in line: found_evtag = True if not found_comment or not found_evtag: print('missing or invalid evtag, aborting') sys.exit(1) subprocess.check_call(['git', 'submodule', 'update', '--checkout', '--', submodule])