From 754bec033b6dc0eed9fa6bbf2d1f2e4486894870 Mon Sep 17 00:00:00 2001 From: Derroylo <72140754+Derroylo@users.noreply.github.com> Date: Sun, 29 Oct 2023 16:56:17 +0100 Subject: [PATCH] Update gpt.yml only when changes have been made (#52) * Update gpt.yml only when changes have been made --- Program.cs | 2 +- helper/internal/config/ConfigHelper.cs | 4 ++++ helper/internal/config/sections/NodeJsConfig.cs | 4 ++++ helper/internal/config/sections/PhpConfig.cs | 4 ++++ helper/internal/config/sections/ServicesConfig.cs | 2 ++ helper/php/PhpIniHelper.cs | 4 ++++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index 4b7da20..b7268bc 100644 --- a/Program.cs +++ b/Program.cs @@ -116,7 +116,7 @@ static void Main(string[] args) app.Run(args); - if (ConfigHelper.ConfigFileExists && ConfigHelper.IsConfigFileValid) { + if (ConfigHelper.ConfigFileExists && ConfigHelper.IsConfigFileValid && ConfigHelper.ConfigUpdated) { try { // Save config file ConfigHelper.SaveConfigFile(); diff --git a/helper/internal/config/ConfigHelper.cs b/helper/internal/config/ConfigHelper.cs index 297e9db..963024f 100644 --- a/helper/internal/config/ConfigHelper.cs +++ b/helper/internal/config/ConfigHelper.cs @@ -12,6 +12,10 @@ class ConfigHelper public static bool ConfigFileExists { get { return configFileExists; } } + private static bool configUpdated = false; + + public static bool ConfigUpdated { get { return configUpdated; } set { configUpdated = value; }} + private static bool configFileValid = false; public static bool IsConfigFileValid { get { return configFileValid; } } diff --git a/helper/internal/config/sections/NodeJsConfig.cs b/helper/internal/config/sections/NodeJsConfig.cs index 3721b6f..b98c7ea 100644 --- a/helper/internal/config/sections/NodeJsConfig.cs +++ b/helper/internal/config/sections/NodeJsConfig.cs @@ -9,6 +9,10 @@ public static string NodeJsVersion } set { + if (appConfig.Nodejs.Version != value) { + ConfigUpdated = true; + } + appConfig.Nodejs.Version = value; } } diff --git a/helper/internal/config/sections/PhpConfig.cs b/helper/internal/config/sections/PhpConfig.cs index 5dc5a15..b52b271 100644 --- a/helper/internal/config/sections/PhpConfig.cs +++ b/helper/internal/config/sections/PhpConfig.cs @@ -11,6 +11,10 @@ public static string PhpVersion } set { + if (appConfig.Php.Version != value) { + ConfigUpdated = true; + } + appConfig.Php.Version = value; } } diff --git a/helper/internal/config/sections/ServicesConfig.cs b/helper/internal/config/sections/ServicesConfig.cs index 028bdf3..dc36f05 100644 --- a/helper/internal/config/sections/ServicesConfig.cs +++ b/helper/internal/config/sections/ServicesConfig.cs @@ -18,6 +18,8 @@ public static List ActiveServices } set { + ConfigUpdated = true; + appConfig.Services.Active = value; } } diff --git a/helper/php/PhpIniHelper.cs b/helper/php/PhpIniHelper.cs index e3092e2..01a2867 100644 --- a/helper/php/PhpIniHelper.cs +++ b/helper/php/PhpIniHelper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Gitpod.Tool.Helper.Internal.Config; using Gitpod.Tool.Helper.Internal.Config.Sections; using Spectre.Console; @@ -99,6 +100,9 @@ public static void AddSettingToPhpIni(string name, string value, bool setForWeb } } + // Manually set that the config has been updated + ConfigHelper.ConfigUpdated = true; + // Update the ini files that are being used by apache and cli UpdatePhpIniFiles(isDebug);