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>
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.
- 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
* 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>
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.
* 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
* 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
* 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
* 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
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.
* 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
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.
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
* 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