@@ -236,6 +236,42 @@ type PluginUpdateAttemptResult =
236236 | { kind : "exception" ; message : string }
237237 | ( { kind : "result" ; result : PluginUpdateInstallResult } & PluginUpdateAttemptState ) ;
238238
239+ function isPluginUpdateUnchanged (
240+ params : Parameters < typeof buildPluginUpdateVersionOutcome > [ 0 ] ,
241+ ) : boolean {
242+ const { record, result, currentVersion, nextVersion } = params ;
243+ const nextCommit = record . source === "git" && "git" in result ? result . git . commit : undefined ;
244+ return record . gitCommit && nextCommit
245+ ? record . gitCommit === nextCommit
246+ : Boolean ( currentVersion && nextVersion && currentVersion === nextVersion ) ;
247+ }
248+
249+ export function buildPluginUpdateVersionOutcome ( params : {
250+ pluginId : string ;
251+ record : UpdatablePluginInstallRecord ;
252+ result : PluginUpdateSuccess ;
253+ currentVersion ?: string ;
254+ nextVersion ?: string ;
255+ channelFallbackSuffix : string ;
256+ channelFallback ?: PluginUpdateChannelFallback ;
257+ } ) : PluginUpdateOutcome {
258+ const currentLabel = params . currentVersion ?? "unknown" ;
259+ const unchanged = isPluginUpdateUnchanged ( params ) ;
260+ const verb = isPackageVersionDowngrade ( params . currentVersion , params . nextVersion )
261+ ? "Downgraded"
262+ : "Updated" ;
263+ return {
264+ pluginId : params . pluginId ,
265+ status : unchanged ? "unchanged" : "updated" ,
266+ currentVersion : params . currentVersion ,
267+ nextVersion : params . nextVersion ,
268+ message : unchanged
269+ ? `${ params . pluginId } already at ${ currentLabel } .${ params . channelFallbackSuffix } `
270+ : `${ verb } ${ params . pluginId } : ${ currentLabel } -> ${ params . nextVersion ?? "unknown" } .${ params . channelFallbackSuffix } ` ,
271+ ...( params . channelFallback ? { channelFallback : params . channelFallback } : { } ) ,
272+ } ;
273+ }
274+
239275export async function buildDryRunPluginUpdateOutcome ( params : {
240276 pluginId : string ;
241277 record : UpdatablePluginInstallRecord ;
@@ -268,16 +304,7 @@ export async function buildDryRunPluginUpdateOutcome(params: {
268304 : undefined ) ;
269305 const nextVersion = resolvedProbeVersion ?? "unknown" ;
270306 const currentLabel = params . currentVersion ?? "unknown" ;
271- const gitProbe =
272- params . record . source === "git" && "git" in params . result ? params . result . git : undefined ;
273- const unchanged =
274- params . record . source === "git" && params . record . gitCommit && gitProbe ?. commit
275- ? params . record . gitCommit === gitProbe . commit
276- : Boolean (
277- params . currentVersion &&
278- resolvedProbeVersion &&
279- params . currentVersion === resolvedProbeVersion ,
280- ) ;
307+ const unchanged = isPluginUpdateUnchanged ( { ...params , nextVersion : resolvedProbeVersion } ) ;
281308 const newerExactPinnedDefaultLine =
282309 unchanged &&
283310 params . record . source === "npm" &&
0 commit comments