Skip to content

Commit 95a7ce0

Browse files
committed
Fix mixed cname with separate version argument parsing
Signed-off-by: Tobias Wolf <[email protected]>
1 parent 22be034 commit 95a7ce0

File tree

6 files changed

+25
-28
lines changed

6 files changed

+25
-28
lines changed

.github/actions/features_parse/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ outputs:
1111
runs:
1212
using: composite
1313
steps:
14-
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].0
14+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].1
1515
- id: result
1616
shell: bash
1717
run: |

.github/actions/flavors_parse/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ outputs:
1313
runs:
1414
using: composite
1515
steps:
16-
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].0
16+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].1
1717
- id: matrix
1818
shell: bash
1919
run: |

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Installs the given GardenLinux Python library
33
inputs:
44
version:
55
description: GardenLinux Python library version
6-
default: "0.8.0"
6+
default: "0.8.1"
77
runs:
88
using: composite
99
steps:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "gardenlinux"
3-
version = "0.8.0"
3+
version = "0.8.1"
44
description = "Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames"
55
authors = ["Garden Linux Maintainers <[email protected]>"]
66
license = "Apache-2.0"

src/gardenlinux/features/__main__.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ def main() -> None:
6565
args.cname
6666
), "Please provide either `--features` or `--cname` argument"
6767

68-
arch = None
68+
arch = args.arch
6969
flavor = None
7070
commit_id = None
7171
gardenlinux_root = path.dirname(args.feature_dir)
72-
version = None
73-
74-
if args.arch is not None:
75-
arch = args.arch
76-
77-
if args.version is not None:
78-
version = args.version
72+
version = args.version
7973

8074
if arch is None or arch == "":
8175
arch = args.default_arch
8276

77+
if gardenlinux_root == "":
78+
gardenlinux_root = "."
79+
8380
if version is None or version == "":
84-
version_data = get_version_and_commit_id_from_files(gardenlinux_root)
85-
version = f"{version_data[0]}-{version_data[1]}"
81+
try:
82+
version_data = get_version_and_commit_id_from_files(gardenlinux_root)
83+
version = f"{version_data[0]}-{version_data[1]}"
84+
except:
85+
version = args.default_version
8686

8787
if args.cname:
8888
cname = CName(args.cname, arch=arch, version=version)
@@ -106,12 +106,6 @@ def main() -> None:
106106

107107
feature_dir_name = path.basename(args.feature_dir)
108108

109-
if gardenlinux_root == "":
110-
gardenlinux_root = "."
111-
112-
if gardenlinux_root == "":
113-
gardenlinux_root = "."
114-
115109
additional_filter_func = lambda node: node not in args.ignore
116110

117111
if args.type == "arch":
@@ -199,6 +193,9 @@ def get_version_and_commit_id_from_files(gardenlinux_root: str) -> tuple[str, st
199193
with open(path.join(gardenlinux_root, "VERSION"), "r") as fp:
200194
version = fp.read().strip()
201195

196+
if commit_id is None or version is None:
197+
raise RuntimeError("Failed to read version or commit ID from files")
198+
202199
return (version, commit_id)
203200

204201

src/gardenlinux/features/cname_main.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ def main():
4444

4545
assert re_match, f"Not a valid GardenLinux canonical name {args.cname}"
4646

47-
arch = None
47+
arch = args.arch
4848
gardenlinux_root = dirname(args.feature_dir)
4949
version = args.version
5050

51-
if args.arch is not None:
52-
arch = args.arch
53-
54-
if args.version is not None:
55-
version = args.version
51+
if gardenlinux_root == "":
52+
gardenlinux_root = "."
5653

5754
if not version:
58-
version_data = get_version_and_commit_id_from_files(gardenlinux_root)
59-
version = f"{version_data[0]}-{version_data[1]}"
55+
try:
56+
version_data = get_version_and_commit_id_from_files(gardenlinux_root)
57+
version = f"{version_data[0]}-{version_data[1]}"
58+
except:
59+
pass
6060

6161
cname = CName(args.cname, arch=arch, version=version)
6262

0 commit comments

Comments
 (0)