Skip to content

Commit

Permalink
Ignore line comments in conanfile.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasberbuer committed Mar 23, 2023
1 parent d16da21 commit dfba4bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Ignore line comments in conanfile.txt

## [0.2.0] - 2022-02-18

Expand All @@ -21,7 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Get requirements directly from conanfile.py/conanfile.txt instead running conan info


## [0.1.0] - 2021-12-16

Initial public release
Expand Down
6 changes: 4 additions & 2 deletions src/conan_check_updates/conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,11 @@ def inspect_requires_conanfile_txt(conanfile: Path) -> List[ConanReference]:
with open(conanfile, mode="r", encoding="utf-8") as file:
key = None
for line in file:
line = line.partition(" #")[0] # strip comment
line = line.strip()
if not line:
# strip end of line comment
line = line.partition(" #")[0].strip()
# ignore empty line or line comments
if not line or line.startswith("#"):
continue
if line.startswith("[") and line.endswith("]"):
key = line[1:-1]
Expand Down
3 changes: 2 additions & 1 deletion tests/conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[requires]
boost/1.79.0
catch2/3.2.0
fmt/9.0.0
# line comment
fmt/9.0.0 # end of line comment
nlohmann_json/3.10.0

[tool_requires]
Expand Down

0 comments on commit dfba4bf

Please sign in to comment.