Commit Graph
410 Commits
Author SHA1 Message Date
Pujitha PaladuguandPujitha Paladugu ce6bcbd775 fix(query): keep pacman.conf repo order for exact name matches (#2987)
Motivation
With separatesources enabled (the default), a package with the exact
searched name that exists in several sync repos can be listed in the
wrong order. For example, if [cachyos-extra-v3] comes before [extra] in
pacman.conf, extra/chromium can still show up as the top pick instead of
cachyos-extra-v3/chromium. pacman prefers the repo listed first.

separateSourceScore returned a flat 50 for every exact match, whatever
its source. As a result, all exact matches got the same metric
(50 + 1.0). The unstable slices.SortFunc then left their relative order
unspecified, so the ordering added for non-exact results did not apply
to exact ones.

Approach
Move the repo-order scoring into a repoOrderScore helper (same logic and
cache as before). For exact matches, add repoOrderScore/separateSourceMax
to the 50: a bonus between 0 and 1. Exact matches still outrank every
non-exact result (which scores at most 45 + a metric below 1). Among
exact matches, repos earlier in pacman.conf now come first. Exact AUR
matches keep 50, so an exact sync-repo match now ranks strictly above an
exact AUR match instead of tying with it. Scoring for non-exact results
is unchanged, and nothing changes when separatesources is disabled.

Validation
- go test -race ./pkg/query/... -count=1: passes.
- New tests TestSourceQueryBuilderExactMatchSortsByRepoOrder (top-down
  and bottom-up) and TestSeparateSourceScore_ExactMatchKeepsRepoOrder
  fail with the previous metric.go and pass with this change.
- golangci-lint run ./pkg/query/...: 0 issues; gofmt clean.
- go test ./... on macOS has failures that also occur on the unchanged
  base: Linux-only syscall fields in pkg/settings/exe, and a
  timezone-dependent test in pkg/text. Not tested against a real
  pacman setup with custom repos.

Report: https://github.com/Jguer/yay/issues/2986

Assisted-by: claude-opus-5-5 (via Claude Code)

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Co-authored-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
2026-09-26 23:56:01 +02:00
Jo 328f4b4939 feat(lua): populate struct slice options from name-keyed tables (#2959) 2026-08-07 16:16:31 +09:00
Jo 514b1df0c2 fix(dep): fall back to pkgbase fields when building packages from .SRCINFO (#2958) 2026-08-07 16:04:28 +09:00
github-actions[bot] 9ae45b9b39 test(query): normalize matcher inputs in unit test (#2942)
test(query): normalize matcher inputs in unit test
2026-08-07 12:05:05 +09:00
Joey Holtzman 19a67d1dbd Add contextual help to Yay operations (#2921)
Instead of `yay -<op> --help` printing the entire help message, it will
now print a contextual help message based on the operation being
performed. The top-level help message shows available operations and
global flags as before. It no longer shows operation-specific flags and
`pacman -S --help` output. Like the pacman output, it shows that you can
get operation-specific help by running `yay -<op> --help`.

The operation-specific help message shows the operation's flags and all
pacman operation flags pass through to pacman.
2026-07-31 03:04:39 +09:00
github-actions[bot]andCopilot c7a6d20e62 [repo-assist] Ignore unknown Lua search-filter results (#2930)
fix(query): ignore unknown search filter results

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-31 02:57:21 +09:00
f43305951a [repo-assist] refactor(srcinfo): deduplicate VCS updates (#2917)
* refactor(srcinfo): deduplicate VCS updates

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix broken test

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jo Garnier <me@jguer.space>
2026-07-31 02:57:02 +09:00
github-actions[bot]andCopilot caab26bfda [repo-assist] test(query): cover multi-term search matching (#2938)
test(query): cover multi-term search matching

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-31 02:56:18 +09:00
github-actions[bot]andCopilot 63f162762b [repo-assist] perf(query): normalize search terms once per query (#2928)
perf(query): normalize search terms once per query

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-31 02:55:56 +09:00
Daniel Kuehn f7c3643c4c fix(diff): place --color flag before pathspec separator (#2933) 2026-07-31 02:34:07 +09:00
Jo 4a5a0f3d33 fix(query): improve multi-term search ranking and filtering (#2926)
- Join search terms with space instead of empty separator so Jaro-Winkler
  similarity compares against realistic strings (e.g. 'linux ck' vs 'linuxck')
- Change matchesSearch symbol check from early return to continue so non-symbol
  terms in multi-term queries are still filtered instead of being bypassed
2026-07-21 21:40:51 +00:00
github-actions[bot] 29f7ed87c4 perf(query): normalize package fields once per search (#2922)
perf(query): normalize package fields once per search
2026-07-20 10:50:41 +02:00
github-actions[bot]andJo Garnier 45964c4b42 [repo-assist] fix(diff): add --no-pager and package header to git diff (#1243) (#2905)
* fix(diff): add --no-pager and package header to git diff

Previously, each package's diff was shown via a separate `git diff`
invocation with Show(), allowing git to invoke its own pager (e.g. less)
independently for each package. This caused inconsistent pagination:
large diffs opened a pager, small diffs scrolled past in the terminal.

Changes:
- Add --no-pager flag to git diff so git doesn't open its own pager
  per package; all diffs now stream consistently to stdout.
- Print a package name header before each diff so users can easily
  identify which package each diff belongs to when reviewing multiple
  packages.

Closes #1243

* bunch up diffs and render in one go

Co-authored-by: Jo Garnier <me@jguer.space>
2026-07-19 02:23:09 +02:00
github-actions[bot] f76bbba9be refactor(workdir): remove unnecessary global NoConfirm mutation in removeMake (#2906)
refactor(workdir): remove unnecessary global NoConfirm mutation in removeMake

removeMake always removes packages non-interactively, so it sets
settings.NoConfirm = true, calls BuildPacmanCmd, then restores the
original value. This pattern is thread-unsafe and redundant because
BuildPacmanCmd already accepts a noConfirm bool parameter.

Pass true directly to BuildPacmanCmd, eliminating the global mutation.
2026-07-19 01:58:04 +02:00
Floze 32a4c9466d fix(sync): prefer repository replacements over matching AUR upgrades (#2910)
fix upgrade handling for repo replacements
2026-07-18 19:43:51 +02:00
Jo 4869306719 feat(search): implement render-hooks for search (#2896)
* add render hooks

* re-render hook per event

* add example with single_line and simplify built rendering

* update docs availability

* remove comments
2026-07-06 14:15:57 +02:00
Jo 19cd422953 query: precompute metricScore and update deps (#2893)
* query: precompute metricScore once per result

Normalize the search term and name/provider/desc at the metric boundary, drop the per-comparison distance cache, and score each result via prepareMetrics before sorting. Adds a search-flow benchmark to track regressions.

* update deps
2026-06-27 16:47:41 +02:00
Jo 6e6d39d595 perf(deps): improve dependency resolution performance (#2890)
* improve topo performance

* fix: Resolve data race in dep_graph_test and clean up local mods

* cleanup

* feat(dep): add split functionality

* cleanup mem allocs
2026-06-24 00:20:04 +02:00
Jo 02fb6ba948 fix(search): fix clober of packages from different sources with the same name (#2882) 2026-06-19 22:39:39 +02:00
Jo d72402292e feat(lua): allow configuring answer menus and minor fixes to examples (#2880)
allow configuring answer menus and minor fixes to examples
2026-06-19 14:31:43 +02:00
Jo 88c72b32b1 fix(lua): change search paths to resolve lua modules in config dir (#2879)
change search paths to not resolve lua modules in cwd but in the config dir
2026-06-19 12:04:12 +02:00
Jo 8fcaff9e6f fix(depgraph): reduce memory allocations (#2875)
* cleanup mem allocs

* lint
2026-06-18 19:58:23 +02:00
Jo 70d7a0f0a8 fix(lua): Reduce event size of PostInstall and SearchFilter hooks (#2871)
* remove fields from events that might not be needed yet

* reduce event size
2026-06-17 21:40:02 +02:00
Jo 15057c8dab misc(ci): add modernize linter and update versioning (#2870)
* add modernize linter

* lint unused

* update imports

* ignore agent info
2026-06-17 21:09:53 +02:00
Jo df4cbc4ce4 fix(log): fix debugln not spacing args correctly (#2869)
* fix debugln not spacing args correctly

* fix tests
2026-06-17 20:39:24 +02:00
Jo 3b3a2b1dcc fix: search filter hooking and multierror cleanup (#2868)
* fix search filtering pass along

* prepare inclusion 'modernize' linter and use errors.join instead
2026-06-17 19:34:33 +02:00
Jo 4dbf124c51 feat(lua): add search filter and post install hooks (#2867)
* search filter and post install

add examples

* add tag
2026-06-16 23:35:18 +02:00
Jo 6927555779 fix: propagate Maintainer field through dep graph and upgrade service (#2865)
* fix: propagate Maintainer field through dep graph and upgrade service

Add Maintainer to InstallInfo and propagate it through the dependency
graph (dep_resolve, dep_visual) and UpgradeService. Update docs
generator with TOC support and Lua page builder.

* lint
2026-06-16 12:19:19 +02:00
Jo 1ec6f3f793 feat: expose AUR package maintainer to upgrade hooks (#2858)
lint
2026-06-15 22:07:49 +02:00
Jo 16479dcaf3 feat: Add AURPostDownload hook (#2856)
* run hooks after source download

* lint

* nitpick: remove event table indirection
2026-06-15 18:10:41 +02:00
Jo 421b65bf43 feat: Add UpgradeSelect hook, logging and security example (#2855)
* add upgrade hook structure

* remove extra field

* feat: Add UpgradeSelect hook logging and security example

Add yay.log API to UpgradeSelect hooks for informational and warning messages.

- Add yay.log.info() and yay.log.warn() for hook logging
- Add doc/examples/recently_modified.lua: practical example to pre-exclude
  recently-modified AUR packages (supply chain attack mitigation)
- Update doc/init.lua with improved UpgradeSelect example
- Update doc/lua.md with logging API documentation
- Refactor autocmd and load modules for cleaner log integration
- Add comprehensive unit tests for logging functionality

* lint
2026-06-15 15:25:40 +02:00
Jo 1501438fba AUR: Add AURPreInstall hooks (#2854)
* add lua hooks on aur package installs

* add abort command to differentiate errors and aborts

* u
2026-06-15 13:31:13 +02:00
rebel onion 977c9562ce feat: Show AUR Package Age (#2846)
* feat: show AUR package age
2026-06-12 11:11:50 +02:00
Jo ecae3e601e Add Lua configuration support (#2845)
* lua opt trial

* go mod tidy
2026-06-09 00:31:26 +02:00
Jo 4c5fda7944 fix(alpm): wire up log callback and add Debug method (#2843)
fix missing callback
2026-06-08 00:18:39 +02:00
Jo ac83d3fb06 Switch to JaroWinkler distance and reweight package search scores (#2840)
fix(query): use JaroWinkler distance and reweight metric components

Switch from Hamming to JaroWinkler distance for package name matching,
as JaroWinkler handles variable-length strings and gives a prefix-match
bonus better suited to package search.

Reweight the score components from sim*0.50 + simDesc*0.20 + popularity*0.30
to sim*0.35 + simDesc*0.15 + popularity*0.50 to better surface popular
packages when name similarity is moderate.

Roll back the unreleased version target from 13.0.0 to 12.6.0 to align
with the next minor release after v12.5.7.

Fix scanner.Err() check in parseStdin to surface I/O errors that were
previously silently dropped.
2026-06-07 18:16:46 +02:00
Jo db19422f2a fix(runtime): use AUR cache in query builder when RPC disabled (#2838)
* fix(runtime): use AUR cache in query builder when RPC disabled

* lint
2026-06-07 00:20:07 +02:00
Jo 50c8291a1e Revert: ini addition to figure out a better customizable system (#2836)
* Revert "feat(ini): support ini config (#2774)"

This reverts commit 3e3d5aa111.

* use base-devel

* fix lint

* fix lint

* fix lint
2026-06-06 23:56:45 +02:00
Jo e6a7c89130 fix: completion cache goroutine races with ALPM handle cleanup (#2835)
* fix: completion cache goroutine races with ALPM handle cleanup

* update go mod

* fix: failed ci builder
2026-06-05 10:23:33 +02:00
Jo 3b79933638 test: harden coverage and make tests parallel-safe (#2797)
* Test coverage hardening and parallel-safe refactors

Add focused test coverage for under-tested operational paths, edge branches,
and make key table-driven suites parallel-safe. Also fixed flaky installer
test execution under repeated/parallel runs.

* chore: fix goimports ordering for golangci-lint

* Test(download): expand integration coverage for download paths

Add integration scenarios for force/pull repo updates, repo-only and skip semantics,
and direct AUR download/scanner coverage used by getpkgbuild and package preparation.

* Test(exe): relax systemd-run path assertion

Fix flaky TestBuildGitCmd by accepting an absolute systemd-run path while still
asserting the expected binary is used.

* Test(text): avoid race in color tests

Remove parallel execution from TestColorHash so global UseColor writes do not
overlap with color consumers in parallel tests and trigger race detector
failures.

* fix potential race conditions
2026-03-25 00:51:34 +01:00
Jo 90ae08862a Remove timeupdate option (#2796)
* disable provides by default

* remove time update due to low usage
2026-03-18 23:01:14 +01:00
TurtleRuss 412c145eb4 fix(query): incorporate AUR popularity into search metric (#2789)
Replace vote-only sigmoid with a blended votes+popularity score in
aurSortByMetric. AUR's Popularity field (already stored and populated
from the API) is a time-decayed vote score that better reflects current
relevance than raw NumVotes alone.

Falls back to votes-only when popularity <= 0 (brand-new packages).
Uses the same sigmoid normalization pattern as the existing minVotes
constant (minPopularity = 0.5).

Side effect: AUR packages no longer artificially outscore repo packages
via historical vote counts when separateSources is disabled. Updated
two noseparatesources test expectations accordingly.
2026-03-15 23:14:54 +01:00
b09f3de913 ci: update golangci-lint to v2.10.1 and bump Go to 1.26 (#2791)
* Initial plan

* ci: update golangci-lint to v2.10.1 and use go 1.26

Co-authored-by: Jguer <8071073+Jguer@users.noreply.github.com>

* fix false report lints

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jguer <8071073+Jguer@users.noreply.github.com>
Co-authored-by: Jo Garnier <git@jguer.space>
2026-03-08 23:33:23 +01:00
JoandCopilot 3e3d5aa111 feat(ini): support ini config (#2774)
* support ini config

* support user ini config

* Update pkg/settings/ini.go

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-30 16:07:24 +01:00
Jo 3d7701fa35 fix: automatically regenerate empty completion cache (#2773)
Fixes #2759

The completion cache validation now checks if the file is empty and
automatically regenerates it. This prevents shell completions from
breaking when the cache file exists but is corrupted or empty.

Previously, NeedsUpdate() only checked file existence and age, but
didn't validate file contents. Empty cache files would be used as-is,
causing 'yay -Pc' to return no output and breaking shell completions.

Changes:
- Add file size check in NeedsUpdate() to detect empty cache files
- Add test case for empty file scenario
- Update function documentation
2026-01-30 10:33:43 +01:00
Jo 0a928ba9f4 feat(yay): use dyalpm for alpm usage (#2769)
* squash: dyalpm integration

* fix vercmp

* fix linting
2026-01-22 16:46:55 +01:00
Jo b2dfa0c56f chore(migration): default to "" as sortBy to keep existing behavior (#2768)
* bump builtin version

* add sortby migration to keep current user behavior
2026-01-22 10:28:47 +01:00
Michele PalazziandJo Garnier 398005c7cd fix: Ensure --asexplicit applies to explicitly targeted packages (#2766)
* fix: Ensure --asexplicit applies to explicitly targeted packages and add a regression test.

Signed-off-by: Michele Palazzi <sysdadmin@m1k.cloud>

* lint

---------

Signed-off-by: Michele Palazzi <sysdadmin@m1k.cloud>
Co-authored-by: Jo Garnier <git@jguer.space>
2026-01-22 09:42:36 +01:00
Joey Holtzman 733e6a6b17 Add support for all sortyby options (#2747)
* Add all sortyby options

Previously, only 'name' was a supported sortby option. Now, all sortby
options are supported.

Whenever there is a tie, the metric is used as a tiebreaker (it is also
the default when sortby is not specified). The only behavior that
changed is that packages with the same metric are sorted oppositely when
sorting bottomUp. This was actually a bug in the previous implementation
which inverts the `cmpResult` for bottomUp which returns true if the
metrics are the same. According to the docs for Less
(https://pkg.go.dev/sort#Interface), Less(i, i) should be false (the
same element cannot sort before itself).

I mainly structured the code for efficiency by creating the sortby
function once rather than checking `separateSources` and `bottomUp`
every comparison, but I also think this improves readability compared to
having a switch-case in the comparison function.

* Fix separating sources on ties and improve test coverage

* Remove 'id' and 'baseid' in sortby options
2026-01-22 09:26:35 +01:00
Jo abe346b2ec Fix flaky test (#2757)
fix flaky test
2025-12-25 14:40:18 +01:00