Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the jguer/yay-builder image as a parent image with archlinux
FROM docker.io/jguer/yay-builder

# Install extra packages (pacman-contrib and fish)
RUN sudo pacman -Syu --noconfirm pacman-contrib fish git-delta openssh bat go github-cli

# Set passwordless sudo for the docker user
RUN echo "docker ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/docker
Comment on lines +7 to +8

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sudo configuration writes directly to /etc/sudoers.d/docker without using visudo or proper permissions. This could be a security risk. The file should have appropriate permissions (0440) to prevent unauthorized modifications. Consider using RUN echo "docker ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/docker && sudo chmod 0440 /etc/sudoers.d/docker

Suggested change
# Set passwordless sudo for the docker user
RUN echo "docker ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/docker
# Set passwordless sudo for the docker user with secure permissions on the sudoers file
RUN echo "docker ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/docker >/dev/null && sudo chmod 0440 /etc/sudoers.d/docker

Copilot uses AI. Check for mistakes.

# Create a non-root user and switch to it

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Create a non-root user and switch to it" but the user 'docker' is already created by the parent image (jguer/yay-builder). This comment is misleading as it only switches to the existing user. Consider updating it to "Switch to the docker user" for accuracy.

Suggested change
# Create a non-root user and switch to it
# Switch to the docker user

Copilot uses AI. Check for mistakes.
USER docker

# Add /app/bin to the PATH
ENV PATH="/app/bin:/home/docker/go/bin:${PATH}"

# Set the working directory
WORKDIR /workspaces/aur

# Command to run when starting the container
CMD ["sleep", "infinity"]
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Existing Dockerfile",
"build": {
"context": "..",
"dockerfile": "../.devcontainer/Dockerfile"
},
"remoteUser": "docker",
"workspaceFolder": "/workspaces/aur",
"customizations": {
"vscode": {
"extensions": [
"golang.go"
]
}
}
}
12 changes: 6 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v9
with:
version: latest
test:
name: Test
strategy:
matrix:
go: ["^1.19"]
os: [macos-latest, windows-latest, ubuntu-latest]
go: ["^1.25"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- name: Test
Expand Down
162 changes: 84 additions & 78 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,18 @@
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 3
min-occurrences: 4
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/Jguer/yay/v11
gomnd:
checks:
- argument
- case
- condition
- return
ignored-numbers:
- '0'
- '1'
- '2'
- '3'
ignored-functions:
- strings.SplitN
govet:
check-shadowing: true
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

version: "2"
run:
go: "1.18"
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
default: none
enable:
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
# - funlen # TOFIX
- gochecknoinits
# - goconst # TOFIX
- gocritic
# - gocyclo # TOFIX
- gofmt
- goimports
# - gomnd # TOFIX
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
Expand All @@ -72,30 +21,87 @@ linters:
- noctx
- nolintlint
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace

run:
go: '1.18'

issues:
exclude-rules:
- path: _test\.go
linters:
- lll
- revive
- wsl
- govet
- godot
- errcheck
- stylecheck
- dupl
- gocritic
- gochecknoinits

exclude:
- G204
settings:
depguard:
rules:
Main:
allow:
- $gostd
- github.com/Jguer/aur
- github.com/Jguer/aur/rpc
- github.com/stretchr/testify/assert
- github.com/stretchr/testify/require
- github.com/stretchr/testify/mock
- github.com/ohler55/ojg/oj
- github.com/itchyny/gojq
- github.com/mitchellh/mapstructure
- github.com/hashicorp/go-multierror
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 3
min-occurrences: 4
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
lll:
line-length: 140
misspell:
locale: US
nolintlint:
require-explanation: false
require-specific: false
allow-unused: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- dupl
- errcheck
- gochecknoinits
- gocritic
- godot
- govet
- lll
- revive
- staticcheck
- wsl
path: _test\.go
- path: (.+)\.go$
text: G204
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/Jguer/yay/v11
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Jguer/aur

go 1.19
go 1.25

require (
github.com/itchyny/gojq v0.12.11
Expand Down
14 changes: 3 additions & 11 deletions rpc/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ func (c *Client) Info(ctx context.Context, pkgs []string) ([]aur.Pkg, error) {
return c.get(ctx, v)
}

func min(a, b int) int {
if a < b {
return a
}

return b
}

func (c *Client) batchInfo(ctx context.Context, names []string) ([]aur.Pkg, error) {
info := make([]aur.Pkg, 0, len(names))
var err error
Expand All @@ -68,13 +60,13 @@ func (c *Client) batchInfo(ctx context.Context, names []string) ([]aur.Pkg, erro
}

for n := 0; n < len(missing); n += c.batchSize {
max := min(len(missing), n+c.batchSize)
maxIdx := min(len(missing), n+c.batchSize)

if c.logFn != nil {
c.logFn("packages to query", missing[n:max])
c.logFn("packages to query", missing[n:maxIdx])
}

tempInfo, requestErr := c.Info(ctx, missing[n:max])
tempInfo, requestErr := c.Info(ctx, missing[n:maxIdx])
if requestErr != nil {
err = multierror.Append(err, requestErr)
continue
Expand Down
2 changes: 1 addition & 1 deletion rpc/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func parseRPCResponse(resp *http.Response) ([]aur.Pkg, error) {
return nil, fmt.Errorf("response decoding failed: %w", err)
}

if len(result.Error) > 0 {
if result.Error != "" {
return nil, &aur.PayloadError{
StatusCode: resp.StatusCode,
ErrorField: result.Error,
Expand Down