1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-18 09:43:47 +01:00
This commit is contained in:
J. Nick Koston
2025-09-16 12:01:01 -05:00
parent c39320c515
commit 452a12892e
2 changed files with 5 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ from esphome.const import (
TYPE_GIT,
TYPE_LOCAL,
)
from esphome.core import CORE
from esphome.core import CORE, TimePeriodSeconds
_LOGGER = logging.getLogger(__name__)
@@ -40,8 +40,9 @@ async def to_code(config):
def _process_git_config(config: dict, refresh, skip_update: bool = False) -> str:
# When skip_update is True, set refresh to None to prevent updates
actual_refresh = None if skip_update else refresh
# When skip_update is True, set a very large refresh value to prevent updates
# Using 100 years in seconds to effectively disable refresh
actual_refresh = TimePeriodSeconds(days=36500) if skip_update else refresh
repo_dir, _ = git.clone_or_update(
url=config[CONF_URL],
ref=config.get(CONF_REF),

View File

@@ -90,7 +90,7 @@ def clone_or_update(
if not file_timestamp.exists():
file_timestamp = Path(repo_dir / ".git" / "HEAD")
age = datetime.now() - datetime.fromtimestamp(file_timestamp.stat().st_mtime)
if refresh is not None and age.total_seconds() > refresh.total_seconds:
if refresh is None or age.total_seconds() > refresh.total_seconds:
old_sha = run_git_command(["git", "rev-parse", "HEAD"], str(repo_dir))
_LOGGER.info("Updating %s", key)
_LOGGER.debug("Location: %s", repo_dir)