[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch wip-filesearch updated: guix: Automatically quote and append wild
From: |
guix-commits |
Subject: |
branch wip-filesearch updated: guix: Automatically quote and append wildcard to filesearch patterns. |
Date: |
Sat, 05 Sep 2020 03:47:58 -0400 |
This is an automated email from the git hooks/post-receive script.
ambrevar pushed a commit to branch wip-filesearch
in repository guix.
The following commit(s) were added to refs/heads/wip-filesearch by this push:
new 25147f9 guix: Automatically quote and append wildcard to filesearch
patterns.
25147f9 is described below
commit 25147f983bdf432b03e8271abe0318f4812f94ba
Author: Pierre Neidhardt <mail@ambrevar.xyz>
AuthorDate: Mon Aug 24 12:47:51 2020 +0200
guix: Automatically quote and append wildcard to filesearch patterns.
* guix/scripts/filesearch.scm (search-file-package): Use
sqlite-bind-arguments
instead of brittle format.
Quote patterns to avoid interpretation of special characters like "-" in
"transmission-gtk".
Append wildcard to search patterns to be smarteer at inferring the
matches (e.g. "perl" should match "perl5").
---
guix/scripts/filesearch.scm | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/guix/scripts/filesearch.scm b/guix/scripts/filesearch.scm
index a409dc1..3cb542d 100644
--- a/guix/scripts/filesearch.scm
+++ b/guix/scripts/filesearch.scm
@@ -138,7 +138,7 @@ matches both \"/bin/foo\" and \"/usr/bin/foo\" but not
\"barbin\"."
#:files (directory-files path)))))
output-path-pairs)))
-(define (search-file-package pattern)
+(define (search-file-package pattern . more-patterns)
"Return corresponding packages.
Packages or ordered by most relevant last.
Path is subject to SQLite \"full-text search\" pattern matching.
@@ -155,10 +155,14 @@ Example patterns:
db
;; REVIEW: Is this inner join cheap?
(string-append
- "select subpath, name, version, output"
- " from Files inner join Packages on Files.package = Packages.id"
- (format #f " where Files.subpath match '~a' order by rank" pattern))
- stmt
+ "SELECT subpath, name, version, output"
+ " FROM Files INNER JOIN Packages ON Files.package = Packages.id"
+ " WHERE Files.subpath MATCH :pattern ORDER BY RANK")
+ stmt
+ (sqlite-bind-arguments stmt #:pattern (string-concatenate
+ (map (lambda (s)
+ (format #f "~s*" s))
+ (cons pattern
more-patterns))))
(map vector->list
(sqlite-fold cons '() stmt)))))
@@ -206,7 +210,7 @@ Example patterns:
;; with xdelta (probably not since it would send entries for Guix versions
;; that the user does not have).
-;; Statistics
+;; Measures
;;
;; Context:
;; - 14,000 packages
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch wip-filesearch updated: guix: Automatically quote and append wildcard to filesearch patterns.,
guix-commits <=