Skip to content

Commit 092709b

Browse files
committed
fix: support empty ref in source patterns
Allow patterns like 'repo@:path' where the ref between @ and : is empty. This enables more lenient parsing where users can explicitly skip the ref while still specifying a path.
1 parent d77f953 commit 092709b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ runs:
7474
REPO="self"
7575
REF=""
7676
CONFIG_PATH="${BASH_REMATCH[1]}"
77-
elif [[ "$SOURCE" =~ ^@([^:]+)(:.*)?$ ]]; then
78-
# Just ref and optional path (e.g., "@main" or "@main:services/api" or "@main:")
77+
elif [[ "$SOURCE" =~ ^@([^:]*)(:.*)?$ ]]; then
78+
# Just ref and optional path (e.g., "@main" or "@main:services/api" or "@main:" or "@:path")
7979
REPO="self"
8080
REF="${BASH_REMATCH[1]}"
8181
CONFIG_PATH="${BASH_REMATCH[2]#:}" # Remove : prefix
82-
elif [[ "$SOURCE" =~ ^([^@:]+)(@[^:]+)?(:.*)?$ ]]; then
83-
# Standard format with repo
82+
elif [[ "$SOURCE" =~ ^([^@:]+)(@[^:]*)?(:.*)?$ ]]; then
83+
# Standard format with repo (allows empty ref like "repo@:path")
8484
REPO="${BASH_REMATCH[1]}"
8585
REF="${BASH_REMATCH[2]#@}" # Remove @ prefix
8686
CONFIG_PATH="${BASH_REMATCH[3]#:}" # Remove : prefix

test-parsing.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ test_pattern() {
1919
REPO="self"
2020
REF=""
2121
CONFIG_PATH="${BASH_REMATCH[1]}"
22-
elif [[ "$SOURCE" =~ ^@([^:]+)(:.*)?$ ]]; then
22+
elif [[ "$SOURCE" =~ ^@([^:]*)(:.*)?$ ]]; then
2323
REPO="self"
2424
REF="${BASH_REMATCH[1]}"
2525
CONFIG_PATH="${BASH_REMATCH[2]#:}"
26-
elif [[ "$SOURCE" =~ ^([^@:]+)(@[^:]+)?(:.*)?$ ]]; then
26+
elif [[ "$SOURCE" =~ ^([^@:]+)(@[^:]*)?(:.*)?$ ]]; then
2727
REPO="${BASH_REMATCH[1]}"
2828
REF="${BASH_REMATCH[2]#@}"
2929
CONFIG_PATH="${BASH_REMATCH[3]#:}"
@@ -67,6 +67,11 @@ test_pattern "self:" "SHOULD_PASS"
6767
test_pattern "Acme/configs:" "SHOULD_PASS"
6868
test_pattern "Acme/configs@main:" "SHOULD_PASS"
6969

70+
# Empty ref patterns (missing ref value between @ and :)
71+
test_pattern "@:services/api" "SHOULD_PASS"
72+
test_pattern "acme-io/kubernetes@:platform-app" "SHOULD_PASS"
73+
test_pattern "Acme/configs@:" "SHOULD_PASS"
74+
7075
# Other edge cases
7176
test_pattern ":" "SHOULD_PASS"
7277
test_pattern "@" "SHOULD_PASS"

0 commit comments

Comments
 (0)