Commit 058d448
fix: support multiple URL protocols (#76)
* Loosened validation of submodule URL.
These aren't strictly "URLs" in the web sense. They may be a variety of
formats and don't strictly conform to HTTP-style URLs, like SSH style
URLs. This change aligns the validation with Git's own URL validation.
While the validation doesn't necessarily gaurantee that the URL is
actually valid, calling the checkout action (which would be necessarily
to use this action anyway) would fail before this if it couldn't clone a
submodule due to a bad URL.
- Switched from `.url()` to `.regex()` string validator using the regex
present in url.c[1] in Git's source code.
- Added unit test and test fixture to check compatibility with SSH-style
URLs.
[1]:
https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/url.c#L6-L12
* Improved remote name extraction.
Since the action no longer accepts HTTP-style URLs, we need to account
for more cases. This commit adds a function that attempts a "best guess"
remote name extraction. It looks for specific characters in the URL that
probably demarcate the remote name. It's not a perfect solution, but it
works well in the vast majority of cases.
- Added `getRemoteName` function to get remote name.
- Added unit tests with a bunch of example cases that cover a gamut of
different URL formats. The test cases were taken from this Stack
Overflow post: https://stackoverflow.com/questions/31801271/what-are-the-supported-git-url-formats
* chore: delete helper function & rename test
---------
Co-authored-by: sgoudham <sgoudham@gmail.com>1 parent 1667558 commit 058d448
File tree
5 files changed
+132
-10
lines changed- dist
- src
- __tests__
- fixtures
5 files changed
+132
-10
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| |||
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
65 | 101 | | |
66 | 102 | | |
67 | 103 | | |
| |||
93 | 129 | | |
94 | 130 | | |
95 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
96 | 165 | | |
97 | 166 | | |
98 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
87 | 115 | | |
88 | 116 | | |
89 | 117 | | |
| |||
94 | 122 | | |
95 | 123 | | |
96 | 124 | | |
97 | | - | |
98 | | - | |
| 125 | + | |
99 | 126 | | |
100 | 127 | | |
101 | 128 | | |
| |||
0 commit comments