Skip to content

Commit

Permalink
Add support for short -i flag
Browse files Browse the repository at this point in the history
  • Loading branch information
cd-work committed Oct 11, 2023
1 parent 54fdbfa commit 7e83fee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lockfile/src/parsers/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ fn line<'a>(input: &'a str, registry: &mut Option<&'a str>) -> IResult<&'a str,
//
// Since `ThirdPartyVersion` only allows a single registry, we only record the
// primary one.
if let Some(index_url) = line.strip_prefix("--index-url") {
if let Some(index_url) =
line.strip_prefix("--index-url ").or_else(|| line.strip_prefix("-i "))
{
*registry = Some(index_url.trim());
line = "";
}
Expand Down
2 changes: 1 addition & 1 deletion lockfile/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ mod tests {
Package {
name: "other-registry".into(),
version: PackageVersion::ThirdParty(ThirdPartyVersion {
registry: "https://mirror1.phylum.io/simple/".into(),
registry: "https://mirror2.phylum.io/simple/".into(),
version: "1.2.3".into(),
}),
package_type: PackageType::PyPi,
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/requirements-locked.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ tomli @ https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a25
-e /tmp/editable ; python_version >= "3.7" and python_version < "3.12"

--index-url https://mirror1.phylum.io/simple/
--extra-index-url https://mirror2.phylum.io/simple/
-i https://mirror2.phylum.io/simple/
--extra-index-url https://mirror3.phylum.io/simple/
other-registry==1.2.3

0 comments on commit 7e83fee

Please sign in to comment.