Skip to content

Commit

Permalink
made gitpython module optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsteve committed Nov 18, 2024
1 parent 5e05673 commit 4400edd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions padre_meddea/io/fits_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"""

import re
import git
from git import InvalidGitRepositoryError

from astropy.io import ascii
import astropy.io.fits as fits
Expand Down Expand Up @@ -80,6 +78,9 @@ def add_process_info_to_header(header: fits.Header, n=1) -> fits.Header:
)
header[f"PRVER{n}A"] = (padre_meddea.__version__, get_std_comment(f"PRVER{n}A"))
try:
import git
from git import InvalidGitRepositoryError

repo = git.Repo(padre_meddea.__file__, search_parent_directories=True)
header[f"PRHSH{n}A"] = (
repo.head.object.hexsha,
Expand All @@ -94,6 +95,8 @@ def add_process_info_to_header(header: fits.Header, n=1) -> fits.Header:
# Time(commits[0].committed_datetime).fits,
# get_std_comment(f"PRVER{n}B"),
# )
except ModuleNotFoundError:
pass
except InvalidGitRepositoryError:
pass

Check warning on line 101 in padre_meddea/io/fits_tools.py

View check run for this annotation

Codecov / codecov/patch

padre_meddea/io/fits_tools.py#L100-L101

Added lines #L100 - L101 were not covered by tests
# primary_hdr["PRLOG1"] add log information, need to do this after the fact
Expand Down

0 comments on commit 4400edd

Please sign in to comment.