Skip to content

Commit

Permalink
v2-lib: fix $ escaping (#759)
Browse files Browse the repository at this point in the history
* auto add labels from a top level structure

* improve message

* fix escaping

* fix escaping

* clean
  • Loading branch information
stavros-k authored Oct 31, 2024
1 parent c3ffb4b commit 5f5cf31
Show file tree
Hide file tree
Showing 50 changed files with 16 additions and 9 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 2 additions & 8 deletions library/2.0.4/formatter.py → library/2.0.5/formatter.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import re
import json
import hashlib


# Replaces all single dollar signs with double dollar signs
# Docker tries to expand shell variables, so we need to
# escape them in multiple places
# It will not replace dollar signs that are already escaped
def escape_dollar(text):
# https://regex101.com/r/tdbI7y/1
return re.sub(r"(?<!\$)\$(?!\$)", r"$$", text)
def escape_dollar(text: str) -> str:
return text.replace("$", "$$")


def get_hashed_name_for_volume(prefix: str, config: dict):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions library/2.0.5/tests/test_formatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from formatter import escape_dollar


def test_escape_dollar():
cases = [
{"input": "test", "expected": "test"},
{"input": "$test", "expected": "$$test"},
{"input": "$$test", "expected": "$$$$test"},
{"input": "$$$test", "expected": "$$$$$$test"},
{"input": "$test$", "expected": "$$test$$"},
]
for case in cases:
assert escape_dollar(case["input"]) == case["expected"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion library/hashes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0.0.1: f074617a82a86d2a6cc78a4c8a4296fc9d168e456f12713e50c696557b302133
1.1.5: 51332f2b032a0c473693458cd93daa96d56604241878e538c07cb85b8be66727
2.0.4: 0e79e3390d3ea73649ee2ac05a4af9ed944a02e95289b5c7e2eb047d475a4651
2.0.5: 0a65beb80aa50e867204d9c6720f8c841047d9e2a0e03d2c949534688c2832e1

0 comments on commit 5f5cf31

Please sign in to comment.