@@ -577,6 +577,8 @@ def git_get_keywords(versionfile_abs):
577577 f.close()
578578 except EnvironmentError:
579579 pass
580+ # CJM: Nibabel hack to ensure we can git-archive off-release versions and
581+ # revert to old X.Y.Zdev versions + githash
580582 try:
581583 rel = runpy.run_path(os.path.join(os.path.dirname(versionfile_abs), "info.py"))
582584 keywords["fallback"] = rel["VERSION"]
@@ -588,8 +590,9 @@ def git_get_keywords(versionfile_abs):
588590@register_vcs_handler("git", "keywords")
589591def git_versions_from_keywords(keywords, tag_prefix, verbose):
590592 """Get version information from git keywords."""
591- if not keywords:
592- raise NotThisMethod("no keywords at all, weird")
593+ # CJM: Nibabel fix to avoid hitting unguarded dictionary lookup, better explanation
594+ if "refnames" not in keywords:
595+ raise NotThisMethod("Short version file found")
593596 date = keywords.get("date")
594597 if date is not None:
595598 # git-2.2.0 added "%%cI", which expands to an ISO-8601 -compliant
@@ -974,6 +977,8 @@ def git_get_keywords(versionfile_abs):
974977 f .close ()
975978 except EnvironmentError :
976979 pass
980+ # CJM: Nibabel hack to ensure we can git-archive off-release versions and
981+ # revert to old X.Y.Zdev versions + githash
977982 try :
978983 rel = runpy .run_path (os .path .join (os .path .dirname (versionfile_abs ), "info.py" ))
979984 keywords ["fallback" ] = rel ["VERSION" ]
@@ -985,8 +990,9 @@ def git_get_keywords(versionfile_abs):
985990@register_vcs_handler ("git" , "keywords" )
986991def git_versions_from_keywords (keywords , tag_prefix , verbose ):
987992 """Get version information from git keywords."""
988- if not keywords :
989- raise NotThisMethod ("no keywords at all, weird" )
993+ # CJM: Nibabel fix to avoid hitting unguarded dictionary lookup, better explanation
994+ if "refnames" not in keywords :
995+ raise NotThisMethod ("Short version file found" )
990996 date = keywords .get ("date" )
991997 if date is not None :
992998 # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
0 commit comments