Skip to content

Commit df291c6

Browse files
fix: ensure GraphConfig.root_dir is an absolute path (#673)
* fix: ensure GraphConfig.root_dir is an absolute path * style: pre-commit.ci auto fixes [...] --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 20222c1 commit df291c6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/taskgraph/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ class GraphConfig:
112112

113113
_PATH_MODIFIED = False
114114

115+
def __post_init__(self):
116+
# ensure we have an absolute path; this is required for assumptions
117+
# made later, such as the `vcs_root` being a directory above `root_dir`
118+
object.__setattr__(self, "root_dir", os.path.abspath(self.root_dir))
119+
115120
def __getitem__(self, name):
116121
return self._config[name]
117122

test/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
import os.path
6+
57
import pytest
68

79
from taskgraph.config import GraphConfig
@@ -10,6 +12,8 @@
1012
def test_graph_config_basic():
1113
graph_config = GraphConfig({"foo": "bar"}, "root")
1214

15+
assert os.path.isabs(graph_config.root_dir)
16+
1317
assert "foo" in graph_config
1418
assert graph_config["foo"] == "bar"
1519
assert graph_config.get("foo") == "bar"

0 commit comments

Comments
 (0)