Skip to content

Commit

Permalink
Colour the first line of a heredoc, and colour output only plans
Browse files Browse the repository at this point in the history
  • Loading branch information
dflook committed Dec 11, 2023
1 parent 949bc76 commit a9ad47b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion image/src/github_pr_comment/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def main() -> int:
changes = os.environ.get('TF_CHANGES') == 'true'

highlighting = ''
if 'Plan:' in body:
if os.environ.get('TF_CHANGES', 'true') == 'true':
highlighting = 'diff' if format_type.startswith('diff') else 'hcl'

comment = update_comment(
Expand Down
2 changes: 0 additions & 2 deletions image/src/github_pr_comment/plan_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def format_diff(plan_text: str) -> str:
continue
elif line.endswith('EOT'):
heredoc = True
lines.append(line)
continue

replaced = (re.sub(
r'^(?P<leading_space>\s+)(?P<operation>[+-/~]+)(?P<trailing>.*)',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_diff_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_heredoc():
# random_string.add will be created
+ resource "random_string" "add" {
+ id = <<EOT
+ id = <<EOT
+ create
- destroy
-/+ destroy and then create replacement
Expand Down

0 comments on commit a9ad47b

Please sign in to comment.