Skip to content

Commit

Permalink
version: degrade quietly if git_info() causes OSError
Browse files Browse the repository at this point in the history
Co-authored-by: Florian Strzelecki <[email protected]>
  • Loading branch information
SnoopJ and Exirel committed Oct 19, 2024
1 parent 9992d1b commit 986ae98
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sopel/builtins/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
from __future__ import annotations

import datetime
import logging
import os
import platform

from sopel import __version__ as release, plugin


logger = logging.getLogger(__name__)


PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
GIT_DIR = os.path.join(PROJECT_DIR, '.git')

Expand Down Expand Up @@ -102,7 +106,12 @@ def version(bot, trigger):
'Sopel v%s' % release,
'Python: %s' % platform.python_version()
]
sha = git_info()
try:
sha = git_info()
except OSError:
logger.warning("Failed to retrieve git commit hash", exc_info=True)
sha = None

if sha:
parts.append('Commit: %s' % sha)

Expand Down

0 comments on commit 986ae98

Please sign in to comment.