diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4eeef40..8acb6bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,9 @@ on: push: branches: - main + - "rework/**" pull_request: + workflow_call: jobs: test: @@ -19,14 +21,17 @@ jobs: go-version-file: go.mod cache: true - - name: Vendor Go modules - run: go mod vendor + - name: gofmt + run: make fmt-check + + - name: go vet + run: make vet + + - name: vendor is up to date + run: make vendor-check - name: Build - run: GOFLAGS=-mod=vendor go build ./... + run: make build - - name: Vet - run: GOFLAGS=-mod=vendor go vet ./... - - - name: Test - run: GOFLAGS=-mod=vendor go test ./... + - name: Test (race) + run: make race diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c4bd8af..1446d60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,19 +13,7 @@ env: jobs: test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true - - - name: Run tests - run: GOFLAGS=-mod=vendor go test ./... + uses: ./.github/workflows/ci.yml release: needs: test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f7039db --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +# Developer and CI entry points. CI (.github/workflows/*.yml) calls these +# targets so local runs and CI stay identical. + +GO ?= go +GOFLAGS ?= -mod=vendor +export GOFLAGS + +# Go sources we own (vendor/ is third-party and not reformatted). +GOFILES = $(shell git ls-files '*.go' | grep -v '^vendor/') + +# Targets mutate vendor/ (vendor-check) and then build from it: never run them +# concurrently, even under `make -j`. +.NOTPARALLEL: + +.PHONY: all build test race lint fmt-check vet vendor-check ci fmt + +all: build + +build: + $(GO) build ./... + +test: + $(GO) test -count=1 ./... + +race: + $(GO) test -race -count=1 ./... + +fmt: + gofmt -w $(GOFILES) + +fmt-check: + @out="$$(gofmt -l $(GOFILES) $$(git ls-files --others --exclude-standard '*.go' | grep -v '^vendor/'))"; \ + if [ -n "$$out" ]; then echo "gofmt needed for:"; echo "$$out"; exit 1; fi + +vet: + $(GO) vet ./... + +# go mod vendor must be a no-op: go.mod, go.sum and vendor/ are committed. +vendor-check: + GOFLAGS= $(GO) mod vendor + git diff --exit-code -- vendor go.mod go.sum + @untracked="$$(git ls-files --others --exclude-standard vendor)"; \ + if [ -n "$$untracked" ]; then echo "untracked files in vendor/:"; echo "$$untracked"; exit 1; fi + +lint: fmt-check vet vendor-check + +ci: lint build race diff --git a/internal/config/session.go b/internal/config/session.go index 1799344..f8d984f 100644 --- a/internal/config/session.go +++ b/internal/config/session.go @@ -12,9 +12,9 @@ import ( // SessionState stores the UI state that should be restored on next launch. type SessionState struct { - ActivePane string `toml:"active_pane"` - Left PaneSession `toml:"left"` - Right PaneSession `toml:"right"` + ActivePane string `toml:"active_pane"` + Left PaneSession `toml:"left"` + Right PaneSession `toml:"right"` } // PaneSession stores per-pane session state (path and selected entry name). diff --git a/internal/fs/ops.go b/internal/fs/ops.go index 789d6c1..4c07c80 100644 --- a/internal/fs/ops.go +++ b/internal/fs/ops.go @@ -94,10 +94,10 @@ func CopyPathWithProgressContext(ctx context.Context, srcPath string, dstDir str progress = func(CopyProgress) {} } tracker := copyProgressState{ - ctx: ctx, - stats: stats, + ctx: ctx, + stats: stats, callback: progress, - stage: "Scanning files...", + stage: "Scanning files...", discover: stats.FilesTotal == 0, } tracker.emit(srcPath, true) diff --git a/internal/ui/model.go b/internal/ui/model.go index bdcbf1d..3977c51 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -237,10 +237,10 @@ type Model struct { archiveProgress chan tea.Msg archiveFormat string deleteKind string // "trash" or "permanent" — selected in delete modal - ssh *sshState - preSSHPath string // original path before entering SSH mode - themeSelector *themeSelectorState // nil when not in theme selector dialog - remoteImageTemp string // temp file of downloaded remote image, cleaned on change/quit + ssh *sshState + preSSHPath string // original path before entering SSH mode + themeSelector *themeSelectorState // nil when not in theme selector dialog + remoteImageTemp string // temp file of downloaded remote image, cleaned on change/quit } func NewModel(cfg config.Config, configPath string) (Model, error) { @@ -1693,8 +1693,6 @@ func (m *Model) refreshAllPanes(status string) (tea.Model, tea.Cmd) { return m, m.loadPreviewCmd() } - - func (m *Model) moveCursor(delta int) { // When a filter query is active on this pane, move through filtered entries // only, so the cursor always lands on a matching item. @@ -6187,8 +6185,12 @@ func (m *Model) startRemoteCopyJob(kind fileOpKind, sources []string, targetDir } if info.IsDir() { err := srcClient.Walk(sourcePath, func(_ string, info os.FileInfo, err error) error { - if err != nil { return err } - if !info.IsDir() { count++ } + if err != nil { + return err + } + if !info.IsDir() { + count++ + } return nil }) if err != nil { @@ -6242,7 +6244,7 @@ func (m *Model) startRemoteCopyJob(kind fileOpKind, sources []string, targetDir var info os.FileInfo var err error - serverSide := false // true if copy/move happened on server without streaming + serverSide := false // true if copy/move happened on server without streaming trackedProgress := false // true if per-file progress callback was used // Get file info and perform copy depending on direction. diff --git a/plans/rework/04-dev-log.md b/plans/rework/04-dev-log.md new file mode 100644 index 0000000..6924e3e --- /dev/null +++ b/plans/rework/04-dev-log.md @@ -0,0 +1,20 @@ +# 04. Журнал разработчика: отклонения от плана + +Короткие записи о местах, где план (`03-tasks.md`) пришлось уточнить или поменять. + +## Этап 0 + +- **0.1 `sshtest`.** Сверх API из §11.2 добавлены: `Options.AuthorizedKeys` (pubkey-auth для будущих тестов + `ssh/conn`), `Server.ClientConfig/Dial/DropConnections/Port`, `Proxy.Sent/Close/Port`, `WriteRandom`. + `Options.Chroot` реализован как рабочий каталог SFTP (`sftp.WithServerWorkingDirectory`) и cwd для exec: + относительные пути разрешаются внутри, но абсолютные выходят наружу — это не граница безопасности (настоящий + chroot для `pkg/sftp` потребовал бы своих request-handlers; для тестов не нужен). `CutAfter(n)` считает + n байт client→server **от момента вызова**, срабатывает один раз и рвёт все текущие соединения; новые + соединения после обрыва принимаются (нужно для тестов reconnect). Задержка `SetDelay` — односторонняя, в обе + стороны (RTT ≈ 2·d). +- **0.4 CI.** `gofmt -l .` из плана задел бы `vendor/` (там 10 неотформатированных файлов сторонних модулей), + поэтому проверяются только наши файлы (`git ls-files '*.go' | grep -v ^vendor/` + неотслеживаемые). + Три файла (`config/session.go`, `fs/ops.go`, `ui/model.go`) были неотформатированы — отформатированы в коммите + 0.4. В `Makefile` стоит `.NOTPARALLEL`, потому что `vendor-check` перезаписывает `vendor/`, а `make -j` + (у разработчика `make` — алиас на `make -j24`) запускал сборку параллельно с этим. `release.yml` вызывает + `ci.yml` через `workflow_call` вместо копии шагов.