aboutsummaryrefslogtreecommitdiff
path: root/src/common.nim
diff options
context:
space:
mode:
authorkitsunyan2018-03-13 23:25:44 +0000
committerkitsunyan2018-03-13 23:25:44 +0000
commit9fceba899e954d77b0aee27d3f084bab4728a770 (patch)
treef77874220784316d050e4c1f4159b05bba17b85a /src/common.nim
parent67d1413bbcbb07636a3267568572b99e0c92f219 (diff)
Filter repeating dependencies
Diffstat (limited to 'src/common.nim')
-rw-r--r--src/common.nim32
1 files changed, 0 insertions, 32 deletions
diff --git a/src/common.nim b/src/common.nim
index eab0750..2da7dc0 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -37,38 +37,6 @@ proc toPackageReference*(dependency: ptr AlpmDependency): PackageReference =
let description = if dependency.desc != nil: some($dependency.desc) else: none(string)
($dependency.name, description, op.map(o => (o, $dependency.version)))
-proc checkConstraints(lop: ConstraintOperation, rop: ConstraintOperation, cmp: int): bool =
- let (x1, x2) = if cmp > 0:
- (1, -1)
- elif cmp < 0:
- (-1, 1)
- else:
- (0, 0)
-
- proc c(op: ConstraintOperation, x1: int, x2: int): bool =
- case op:
- of ConstraintOperation.eq: x1 == x2
- of ConstraintOperation.ge: x1 >= x2
- of ConstraintOperation.le: x1 <= x2
- of ConstraintOperation.gt: x1 > x2
- of ConstraintOperation.lt: x1 < x2
-
- template a(x: int): bool = lop.c(x, x1) and rop.c(x, x2)
-
- a(2) or a(1) or a(0) or a(-1) or a(-2)
-
-proc isProvidedBy*(package: PackageReference, by: PackageReference): bool =
- if package.name == by.name:
- if package.constraint.isNone or by.constraint.isNone:
- true
- else:
- let lcon = package.constraint.unsafeGet
- let rcon = package.constraint.unsafeGet
- let cmp = vercmp(lcon.version, rcon.version)
- checkConstraints(lcon.operation, rcon.operation, cmp)
- else:
- false
-
proc checkAndRefresh*(color: bool, args: seq[Argument]): tuple[code: int, args: seq[Argument]] =
let refreshCount = args.count((some("y"), "refresh"))
if refreshCount > 0: