X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fbin%2Fgit-update-and-verify-submodule;fp=shell%2Fbin%2Fgit-update-and-verify-submodule;h=c4ba1f621d4e3bce1697ff5089977cdbe97f0547;hb=4af4ee14bf8b6d8938ba6615c1af4389453a213a;hp=0000000000000000000000000000000000000000;hpb=3838df1c0ce1c544d6522f100530b60fb7d81015;p=config%2Fdotfiles.git diff --git a/shell/bin/git-update-and-verify-submodule b/shell/bin/git-update-and-verify-submodule new file mode 100755 index 0000000..c4ba1f6 --- /dev/null +++ b/shell/bin/git-update-and-verify-submodule @@ -0,0 +1,51 @@ +#!/usr/bin/python + +# Copyright (C) 2018 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]).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]) + +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])