Skip to content

Commit

Permalink
Revert "Support resolving application if rid name is encoded into the…
Browse files Browse the repository at this point in the history
… application id."

This reverts commit 217a85a.
  • Loading branch information
peters committed Oct 1, 2020
1 parent ca47672 commit e3fd651
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions src/Snapx/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,30 +450,10 @@ static bool MaybeOverrideLockToken([NotNull] SnapApps snapApps, [NotNull] ILog l
if (workingDirectory == null) throw new ArgumentNullException(nameof(workingDirectory));

var (snapApps, snapAppTargets, _, snapsAbsoluteFilename) = BuildSnapAppsesFromDirectory(filesystem, reader, nuGetPackageSources, workingDirectory);

var snapApp = ApplicationIdAndRid() ?? ApplicationIdContainsRid();
var snapApp = snapAppTargets.SingleOrDefault(x => string.Equals(x.Id, id, StringComparison.OrdinalIgnoreCase)
&& string.Equals(x.Target.Rid, rid, StringComparison.OrdinalIgnoreCase));

return (snapApps, snapApp, snapApps == null, snapsAbsoluteFilename);

SnapApp ApplicationIdAndRid()
{
return snapAppTargets.SingleOrDefault(x => string.Equals(x.Id, id, StringComparison.OrdinalIgnoreCase)
&& string.Equals(x.Target.Rid, rid, StringComparison.OrdinalIgnoreCase));
}

SnapApp ApplicationIdContainsRid()
{
return snapAppTargets.SingleOrDefault(x =>
{
// Application id contains the rid, e.g. demoapp-linux-x64.
if (!x.Id.Contains("-", StringComparison.OrdinalIgnoreCase)) return false;
var lastDashPosition = x.Id.IndexOf("-", StringComparison.OrdinalIgnoreCase);
if (lastDashPosition == -1) return false;
var lhsIdAndRid = $"{x.Id.Substring(0, lastDashPosition)}-{x.Target.Rid}";
var rhsIdAndRid = $"{id}-{rid}";
return string.Equals(lhsIdAndRid, rhsIdAndRid, StringComparison.OrdinalIgnoreCase);
});
}
}

static (SnapApps snapApps, List<SnapApp> snapAppTargets, bool error, string snapsAbsoluteFilename) BuildSnapAppsesFromDirectory(
Expand Down

0 comments on commit e3fd651

Please sign in to comment.