Skip to content

Commit 49429f6

Browse files
Align pin parity with packaged winget
1 parent d69606a commit 49429f6

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

‎dotnet/src/Devolutions.Pinget.Core.Tests/CoreTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ PRIMARY KEY (package_id, source_id)
688688

689689
using var reader = verifyCmd.ExecuteReader();
690690
Assert.True(reader.Read());
691-
Assert.Equal(2L, reader.GetInt64(0));
691+
Assert.Equal(3L, reader.GetInt64(0));
692692
Assert.Equal("1.2.*", reader.GetString(1));
693693
}
694694
finally

‎dotnet/src/Devolutions.Pinget.Core/PinStore.cs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ PRIMARY KEY (package_id, source_id)
6666

6767
int typeInt = pinType switch
6868
{
69-
PinType.Blocking => 1,
70-
PinType.Gating => 2,
71-
_ => 0
69+
PinType.Blocking => 4,
70+
PinType.Gating => 3,
71+
_ => 2
7272
};
7373

7474
using var cmd = conn.CreateCommand();
@@ -157,8 +157,8 @@ private static PinType ToPinType(long pinTypeValue)
157157
{
158158
return pinTypeValue switch
159159
{
160-
1 => PinType.Blocking,
161-
2 => PinType.Gating,
160+
4 => PinType.Blocking,
161+
3 => PinType.Gating,
162162
_ => PinType.Pinning
163163
};
164164
}

‎rust/crates/pinget-core/src/lib.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,9 +1130,9 @@ impl Repository {
11301130
)?;
11311131
let pin_type_column = resolve_pin_type_column(&conn)?.unwrap_or("type");
11321132
let type_int: i64 = match pin_type {
1133-
PinType::Pinning => 0,
1134-
PinType::Blocking => 1,
1135-
PinType::Gating => 2,
1133+
PinType::Pinning => 2,
1134+
PinType::Blocking => 4,
1135+
PinType::Gating => 3,
11361136
};
11371137
conn.execute(
11381138
&format!(
@@ -5563,8 +5563,8 @@ fn resolve_pin_type_column(conn: &Connection) -> Result<Option<&'static str>> {
55635563

55645564
fn decode_pin_type(pin_type_int: i64) -> PinType {
55655565
match pin_type_int {
5566-
1 => PinType::Blocking,
5567-
2 => PinType::Gating,
5566+
4 => PinType::Blocking,
5567+
3 => PinType::Gating,
55685568
_ => PinType::Pinning,
55695569
}
55705570
}
@@ -7749,7 +7749,7 @@ Installers:
77497749
rusqlite::params!["Contoso.Tool", "winget"],
77507750
|row| Ok((row.get::<_, i64>(0)?, row.get::<_, String>(1)?)),
77517751
)?;
7752-
assert_eq!(stored_pin.0, 2);
7752+
assert_eq!(stored_pin.0, 3);
77537753
assert_eq!(stored_pin.1, "1.2.*");
77547754

77557755
Ok(())

‎rust/tools/Smoke-Compare-WingetParity.ps1‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,9 @@ function Test-PinVisible {
571571
[switch]$SystemCli
572572
)
573573

574-
$commandArgs = if ($SystemCli) {
575-
@("pin", "list", "--accept-source-agreements", "--disable-interactivity")
576-
}
577-
else {
578-
@("pin", "list", $PackageId)
574+
$commandArgs = @("pin", "list", "--id", $PackageId, "--exact")
575+
if ($SystemCli) {
576+
$commandArgs += @("--accept-source-agreements", "--disable-interactivity")
579577
}
580578

581579
$result = Invoke-Capture -Executable $Executable -Arguments $commandArgs
@@ -590,7 +588,7 @@ function Remove-PinIfPresent {
590588
)
591589

592590
if (Test-PinVisible -Executable $Executable -PackageId $PackageId -SystemCli:$SystemCli) {
593-
$removeArgs = @("pin", "remove", $PackageId)
591+
$removeArgs = @("pin", "remove", "--id", $PackageId, "--exact")
594592
if ($SystemCli) {
595593
$removeArgs += @("--accept-source-agreements", "--disable-interactivity")
596594
}

0 commit comments

Comments
 (0)