Last active
October 22, 2020 06:55
-
-
Save japm48/1a728b589dfbd311ca13ba0126f4f50c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires fd: https://github.com/sharkdp/fd | |
gr_update_hash() | |
{ | |
git status 2>/dev/null >/dev/null || { echo 'not in git repo' ; return; } | |
[ "$#" -ne 0 ] || { echo 'need list of args (base filenames)'; return; } | |
root=$(git rev-parse --show-toplevel) | |
fd_cmd='fd --type f --color never --max-results=1' | |
for f in "$@" | |
do | |
( | |
cd "$root" | |
h=$($fd_cmd "^${f}.h\$") | |
[ -z $h ] && { echo "$f.h not found"; return; } | |
ccp=$($fd_cmd "^${f}_python.cc\$") | |
[ -z $ccp ] && { echo "${f}_python.cc not found"; return; } | |
hhash=$(md5sum $h | awk '{print $1}') | |
echo "$f - $hhash" | |
sed -i -r "s/(BINDTOOL_HEADER_FILE_HASH)[(].*[)]/\1($hhash)/" "$ccp" | |
) | |
done | |
} | |
# Zero-Clause BSD (no attribution required, GPL-compatible) | |
# SPDX-License-Identifier: 0BSD | |
# Full text here: https://opensource.org/licenses/0BSD | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment