MCPcopy Index your code
hub / github.com/secdev/scapy / _version_from_git_archive

Function _version_from_git_archive

scapy/__init__.py:48–79  ·  view source on GitHub ↗

Rely on git archive "export-subst" git attribute. See 'man gitattributes' for more details. Note: describe is only supported with git >= 2.32.0, and the `tags=true` option with git >= 2.35.0 but we use it to workaround GH#3121.

()

Source from the content-addressed store, hash-verified

46
47
48def _version_from_git_archive():
49 # type: () -> str
50 """
51 Rely on git archive "export-subst" git attribute.
52 See 'man gitattributes' for more details.
53 Note: describe is only supported with git >= 2.32.0,
54 and the `tags=true` option with git >= 2.35.0 but we
55 use it to workaround GH#3121.
56 """
57 git_archive_id = '$Format:%ct %(describe:tags=true)$'.split()
58 tstamp = git_archive_id[0]
59 if len(git_archive_id) > 1:
60 tag = git_archive_id[1]
61 else:
62 # project is run in CI and has another %(describe)
63 tag = ""
64
65 if "Format" in tstamp:
66 raise ValueError('not a git archive')
67
68 if "describe" in tag:
69 # git is too old!
70 tag = ""
71 if tag:
72 # archived revision is tagged, use the tag
73 return _parse_tag(tag)
74 elif tstamp:
75 # archived revision is not tagged, use the commit date
76 d = datetime.datetime.fromtimestamp(int(tstamp), datetime.timezone.utc)
77 return d.strftime('%Y.%m.%d')
78
79 raise ValueError("invalid git archive format")
80
81
82def _version_from_git_describe():

Callers 1

_versionFunction · 0.85

Calls 1

_parse_tagFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…