Ensure setup.yml and requirements.yml are updated when .all.yml files change

This commit is contained in:
Slavi Pantaleev 2023-11-20 11:05:18 +02:00
parent e181d66cdf
commit 3273f475bb
2 changed files with 24 additions and 6 deletions

3
.gitignore vendored
View file

@ -11,4 +11,7 @@
.DS_Store .DS_Store
/requirements.yml /requirements.yml
/requirements.yml.srchash
/setup.yml /setup.yml
/setup.yml.srchash

View file

@ -62,14 +62,29 @@ stop-group group *extra_args:
# Prepares the requirements.yml file # Prepares the requirements.yml file
requirements-yml: requirements-yml:
#!/usr/bin/env sh @just --justfile {{ justfile() }} _ensure_file_prepared {{ justfile_directory() }}/requirements.all.yml {{ justfile_directory() }}/requirements.yml
if [ ! -f "{{ justfile_directory() }}/requirements.yml" ]; then
cp {{ justfile_directory() }}/requirements.all.yml {{ justfile_directory() }}/requirements.yml
fi
# Prepares the setup.yml file # Prepares the setup.yml file
setup-yml: setup-yml:
@just --justfile {{ justfile() }} _ensure_file_prepared {{ justfile_directory() }}/setup.all.yml {{ justfile_directory() }}/setup.yml
_ensure_file_prepared src_path dst_path:
#!/usr/bin/env sh #!/usr/bin/env sh
if [ ! -f "{{ justfile_directory() }}/setup.yml" ]; then hash_path={{ dst_path }}.srchash
cp {{ justfile_directory() }}/setup.all.yml {{ justfile_directory() }}/setup.yml src_hash=$(md5sum {{ src_path }} | cut -d ' ' -f 1)
if [ ! -f "{{ dst_path }}" ] || [ ! -f "$hash_path" ]; then
echo "One of the ORS"
cp {{ src_path }} {{ dst_path }}
echo $src_hash > $hash_path
else
current_hash=$(cat $hash_path)
if [ "$current_hash" != "$src_hash" ]; then
echo "Hash is different ($current_hash != $src_hash)"
cp {{ src_path }} {{ dst_path }}
echo $src_hash > $hash_path
else
echo "Hash matches!"
fi
fi fi