From be800902d6e572e233a6cedff718c11cc85ffc37 Mon Sep 17 00:00:00 2001 From: Paul Brown <67805647+pb-dod@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:55:11 -0500 Subject: [PATCH] DP-3498: ensure auto-update-repositories plist is in sync (#97) This PR introduces enhancements to the test-or-install function within our tool repositories setup script. The primary goal of these changes is to ensure that the plist file (com.includedhealth.auto-update-repositories.plist) is always kept in sync with its source version located in the core library directory. --- VERSION | 2 +- formula/ih-core.rb | 2 +- lib/core/toolrepos/step.sh | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index c52af3e..920c3bd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.56 +0.1.57 diff --git a/formula/ih-core.rb b/formula/ih-core.rb index 32cc8a4..97e2a5d 100644 --- a/formula/ih-core.rb +++ b/formula/ih-core.rb @@ -1,5 +1,5 @@ class IhCore < Formula - VERSION="0.1.56" + VERSION="0.1.57" desc "Brew formula for installing core tools used at Included Health engineering." homepage "https://github.com/ConsultingMD/homebrew-ih-public" license "CC BY-NC-ND 4.0" diff --git a/lib/core/toolrepos/step.sh b/lib/core/toolrepos/step.sh index 8daa8c2..36b4916 100644 --- a/lib/core/toolrepos/step.sh +++ b/lib/core/toolrepos/step.sh @@ -54,17 +54,19 @@ function ih::setup::core.toolrepos::test-or-install() { git clone git@github.com:ConsultingMD/kore.git --filter=blob:limit=1m --depth=5 "${GR_HOME}/kore" || return fi - local toolsrepo_src_path="$IH_CORE_LIB_DIR/core/toolrepos/default/10_toolrepos.sh" - local toolsrepo_tgt_path="$IH_DEFAULT_DIR/10_toolrepos.sh" - - PLIST_FILE="$HOME/Library/LaunchAgents/com.includedhealth.auto-update-repositories.plist" - if [ ! -f "$PLIST_FILE" ]; then + local plist_src_path="$IH_CORE_LIB_DIR/core/toolrepos/autoupdate/com.includedhealth.auto-update-repositories.plist" + local plist_tgt_path="$HOME/Library/LaunchAgents/com.includedhealth.auto-update-repositories.plist" + if [ ! -f "$plist_tgt_path" ] || ! ih::file::check-file-in-sync "$plist_src_path" "$plist_tgt_path"; then if [ "$1" == "test" ]; then return 1 fi + cp -f "$plist_src_path" "$plist_tgt_path" + ih::log::info "Plist file updated." ih::setup::core.toolrepos::set-auto-update-repositories-job fi + local toolsrepo_src_path="$IH_CORE_LIB_DIR/core/toolrepos/default/10_toolrepos.sh" + local toolsrepo_tgt_path="$IH_DEFAULT_DIR/10_toolrepos.sh" if ! ih::file::check-file-in-sync "$toolsrepo_src_path" "$toolsrepo_tgt_path"; then if [ "$1" = "test" ]; then return 1 @@ -101,11 +103,9 @@ manually in order to have pre-commit configured correctly." } function ih::setup::core.toolrepos::set-auto-update-repositories-job() { - local THIS_DIR="$IH_CORE_LIB_DIR/core/toolrepos/autoupdate" - - PLIST_FILE="com.includedhealth.auto-update-repositories" - LAUNCH_AGENTS_PATH="${HOME}/Library/LaunchAgents/${PLIST_FILE}.plist" + local PLIST_FILE="com.includedhealth.auto-update-repositories" + local LAUNCH_AGENTS_PATH="${HOME}/Library/LaunchAgents/${PLIST_FILE}.plist" # shellcheck disable=SC2001 GR_HOME_ESC=$(echo "$GR_HOME" | sed 's_/_\\/_g') @@ -120,4 +120,5 @@ function ih::setup::core.toolrepos::set-auto-update-repositories-job() { launchctl load "${LAUNCH_AGENTS_PATH}" + ih::log::info "Plist file loaded successfully: $LAUNCH_AGENTS_PATH" }