mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
ci/collect-repo-info: Make plugin VERSION reading more robust
The zeek-kafak plugin's VERSION file contains a commented license header followed by an empty line, followed by the actual version. Attempt to deal with this by using the first non-commented non-empty line.
This commit is contained in:
parent
bfd182f583
commit
42c1fc3e7d
1 changed files with 14 additions and 1 deletions
|
@ -116,6 +116,19 @@ def collect_git_info(zeek_dir: pathlib.Path):
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
def read_plugin_version(plugin_dir: pathlib.Path):
|
||||||
|
"""
|
||||||
|
Open the VERSION file, look for the first non empty
|
||||||
|
non comment line and return it.
|
||||||
|
"""
|
||||||
|
with (plugin_dir / "VERSION").open() as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if line and not line.startswith("#"):
|
||||||
|
return line
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def collect_plugin_info(plugin_dir: pathlib.Path):
|
def collect_plugin_info(plugin_dir: pathlib.Path):
|
||||||
""" """
|
""" """
|
||||||
# A plugin's name is not part of it's metadata/information, use
|
# A plugin's name is not part of it's metadata/information, use
|
||||||
|
@ -125,7 +138,7 @@ def collect_plugin_info(plugin_dir: pathlib.Path):
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result["version"] = (plugin_dir / "VERSION").read_text().strip()
|
result["version"] = read_plugin_version(plugin_dir)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.warning("No VERSION found in %s", plugin_dir)
|
logger.warning("No VERSION found in %s", plugin_dir)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue