aboutsummaryrefslogtreecommitdiff
path: root/src/feature
diff options
context:
space:
mode:
authorkitsunyan2018-04-22 23:08:49 +0000
committerkitsunyan2018-04-22 23:08:49 +0000
commit6ffcd68b64f4199b33c8fdd5377cc932466d22de (patch)
tree37bbc2fb783584cdf2dc5f916945ed6403e86c15 /src/feature
parenta1a5e345daaeae0fae1da58e3683041d48e2583a (diff)
Add support for version constraints for sync info
Diffstat (limited to 'src/feature')
-rw-r--r--src/feature/syncinfo.nim16
-rw-r--r--src/feature/syncinstall.nim6
2 files changed, 13 insertions, 9 deletions
diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim
index d00dcc0..30f6f20 100644
--- a/src/feature/syncinfo.nim
+++ b/src/feature/syncinfo.nim
@@ -61,7 +61,7 @@ proc formatDate(date: Option[int64]): seq[string] =
proc handleTarget(config: Config, padding: int, args: seq[Argument],
target: FullPackageTarget[PackageInfo]): int =
- if target.foundInfo.isSome:
+ if target.foundInfos.len > 0:
if isAurTargetFull[PackageInfo](target):
let pkgInfo = target.pkgInfo.unsafeGet
@@ -85,16 +85,19 @@ proc handleTarget(config: Config, padding: int, args: seq[Argument],
(tr"Rating", @[formatPkgRating(pkgInfo.votes, pkgInfo.popularity)], false))
0
+ elif target.reference.constraint.isSome:
+ # pacman doesn't support constraints for --info queries
+ pacmanRun(false, config.color, args & target.foundInfos.map(i =>
+ (i.repo & "/" & target.reference.name, none(string), ArgumentType.target)))
else:
pacmanRun(false, config.color, args &
- (target.formatArgument, none(string), ArgumentType.target))
+ ($target, none(string), ArgumentType.target))
else:
if target.repo == some("aur"):
- printError(config.color, trp("package '%s' was not found\n") % [target.formatArgument])
+ printError(config.color, trp("package '%s' was not found\n") % [$target])
1
else:
- pacmanRun(false, config.color, args &
- (target.formatArgument, none(string), ArgumentType.target))
+ pacmanRun(false, config.color, args & ($target, none(string), ArgumentType.target))
proc handleSyncInfo*(args: seq[Argument], config: Config): int =
let (_, callArgs) = checkAndRefresh(config.color, args)
@@ -112,7 +115,8 @@ proc handleSyncInfo*(args: seq[Argument], config: Config): int =
let fullTargets = mapAurTargets[PackageInfo](syncTargets, pkgInfos)
let code = min(aerrors.len, 1)
- if fullTargets.filter(isAurTargetFull[PackageInfo]).len == 0:
+ if fullTargets.filter(t => isAurTargetFull[PackageInfo](t) or t.repo == some("aur")).len == 0 and
+ fullTargets.filter(t => t.reference.constraint.isSome).len == 0:
if code == 0:
pacmanExec(false, config.color, callArgs)
else:
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 163bf34..ecca6ef 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -211,7 +211,7 @@ proc filterNotFoundSyncTargetsInternal(syncTargets: seq[SyncPackageTarget],
upToDateNeededTable: Table[string, PackageReference]): seq[SyncPackageTarget] =
# collect packages which were found neither in sync DB nor in AUR
syncTargets.filter(t => not (upToDateNeededTable.opt(t.reference.name)
- .map(r => t.reference.isProvidedBy(r)).get(false)) and t.foundInfo.isNone and
+ .map(r => t.reference.isProvidedBy(r)).get(false)) and t.foundInfos.len == 0 and
not (t.isAurTargetSync and pkgInfoReferencesTable.opt(t.reference.name)
.map(r => t.reference.isProvidedBy(r)).get(false)))
@@ -1071,7 +1071,7 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
let neededPacmanTargets = if printFormat.isNone and build and needed:
pacmanTargets.filter(target => (block:
- let version = target.foundInfo.get.pkg.get.version
+ let version = target.foundInfos[0].pkg.get.version
if installedTable.checkNeeded(target.reference.name, version, true).needed:
true
else:
@@ -1138,7 +1138,7 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
let fullPkgInfos = finalPkgInfos & lc[i | (s <- satisfied.values,
i <- s.buildPkgInfo, not (i.name in buildAndAurTargetSet)), PackageInfo].deduplicate
- let directPacmanTargets = pacmanTargets.map(t => t.formatArgument)
+ let directPacmanTargets = pacmanTargets.map(`$`)
let additionalPacmanTargets = lc[x.name | (x <- satisfied.values,
not x.installed and x.buildPkgInfo.isNone), string]
let orderedPkgInfos = orderInstallation(fullPkgInfos, satisfied)