Skip to content

Commit 47477cf

Browse files
committed
Merge remote-tracking branch 'origin/main' into CBG-5425
2 parents 40b5699 + d8545a9 commit 47477cf

319 files changed

Lines changed: 13179 additions & 3652 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ env:
3535
ACTIONS_CHECKOUT_VERSION: &actions_checkout_version actions/checkout@v6
3636
ACTIONS_SETUP_GO_VERSION: &actions_setup_go_version actions/setup-go@v6
3737
ACTIONS_RUFF_VERSION: &actions_ruff_version astral-sh/ruff-action@v4.0.0
38-
GO_VERSION: &go_version 1.26.3
38+
GO_VERSION: &go_version 1.26.4
3939
GOTESTSUM_VERSION: 1.13.0
4040
GO_TEST_ANNOTATIONS_VERSION: &go_test_annotations_version guyarb/golang-test-annotations@v0.9.0
4141

.github/workflows/service.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
# build sync gateway since the executable is needed for service installation
4848
- uses: actions/setup-go@v6
4949
with:
50-
go-version: 1.26.3
50+
go-version: 1.26.4
5151
- name: "Build Sync Gateway"
5252
run: mkdir -p ./bin && go build -o ./bin ./...
5353
- name: "Run test scripts"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ tools/stats-definition-exporter/stats-definition-exporter
2929
.cbcache/
3030

3131
planPIndexes/
32+
33+
couchbase-lite-tests
34+
integration-test/e2e/.gitconfig.e2e

.pre-commit-config.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright 2024-Present Couchbase, Inc.
2+
#
3+
# Use of this software is governed by the Business Source License included in
4+
# the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that
5+
# file, in accordance with the Business Source License, use of this software
6+
# will be governed by the Apache License, Version 2.0, included in the file
7+
# licenses/APL2.txt.
8+
9+
repos:
10+
- repo: local
11+
hooks:
12+
- id: addlicense
13+
name: addlicense
14+
language: system
15+
entry: go run github.com/google/addlicense@latest -f licenses/addlicense.tmpl
16+
types_or: [go, python]
17+
18+
- id: goimports
19+
name: goimports
20+
language: system
21+
entry: go run golang.org/x/tools/cmd/goimports@latest
22+
args: [-w]
23+
types: [go]
24+
25+
- id: golangci-lint
26+
name: golangci-lint
27+
language: system
28+
# version must match .github/workflows/ci.yml golangci job
29+
entry: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
30+
args: [run, --config=.golangci-strict.yml, --fix=false]
31+
types: [go]
32+
pass_filenames: false
33+
34+
- id: ruff-format
35+
name: ruff format
36+
language: system
37+
entry: uv run -- ruff format
38+
types: [python]
39+
40+
- id: mypy
41+
name: mypy
42+
language: system
43+
entry: uv run -- mypy
44+
pass_filenames: false
45+
files: ^(pyproject\.toml|.*\.py)$
46+
47+
- id: manifest-product-config-sorted
48+
name: manifest/product-config.json keys sorted
49+
language: system
50+
entry: bash -c 'diff <(jq --sort-keys . manifest/product-config.json) <(jq . manifest/product-config.json)'
51+
files: ^manifest/product-config\.json$
52+
pass_filenames: false
53+
54+
- id: redocly-lint
55+
name: redocly lint
56+
language: system
57+
entry: npx --yes @redocly/cli@2 lint --config=.redocly.yaml --format=stylish
58+
files: ^(docs/api/|\.redocly\.yaml$)
59+
pass_filenames: false
60+
61+
- id: yamllint
62+
name: yamllint
63+
language: system
64+
entry: yamllint
65+
args: [docs/api]
66+
files: ^docs/api/
67+
pass_filenames: false
68+
69+
- id: shellcheck
70+
name: shellcheck
71+
language: system
72+
entry: shellcheck
73+
types: [shell]
74+
exclude: >-
75+
(?x)^(
76+
build\.sh|
77+
bootstrap\.sh|
78+
bench\.sh|
79+
build/postinst\.tmpl|
80+
build/postrm\.tmpl|
81+
integration-test/service-test\.sh|
82+
integration-test/service-install-tests\.sh|
83+
rewrite-manifest\.sh|
84+
snap-manifest\.sh|
85+
set-version-stamp\.sh|
86+
service/sync_gateway_service_install\.sh|
87+
service/sync_gateway_service_uninstall\.sh|
88+
service/sync_gateway_service_upgrade\.sh|
89+
test-integration-init\.sh|
90+
test\.sh
91+
)$

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,35 @@ Download Sync Gateway and other Couchbase packages for Linux, Windows and macOS
2222

2323
### Pre-requisites
2424

25-
To build Sync Gateway from source, you must have the following installed:
26-
27-
* Go 1.21 or later ([Installing Go](https://golang.org/doc/install))
2825
* Building the Enterprise Edition requires access to private code, and cannot be built by third-parties.
2926

30-
### Build Instructions
27+
### Build Instructions
3128

3229
```shell
3330
$ go build
3431
```
3532

33+
## Contributing
34+
35+
### Pre-commit hooks
36+
37+
Pre-commit is optional — it's a convenience to catch issues locally before CI does. Run once per checkout to enable it:
38+
39+
```shell
40+
uvx pre-commit install
41+
```
42+
43+
After that, the hooks run automatically whenever you `git commit`. `uvx` ships with [uv](https://docs.astral.sh/uv/getting-started/installation/).
44+
45+
#### Running hooks manually
46+
47+
If you need to run the hooks outside of a commit:
48+
49+
```shell
50+
uvx pre-commit run # staged files only
51+
uvx pre-commit run --all-files # entire repo
52+
```
53+
3654
## Resources
3755

3856
- [Sync Gateway Documentation][SG_DOCS]

auth/auth.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,17 @@ func (auth *Authenticator) Save(p Principal) error {
428428
return nil
429429
}
430430

431-
// Used for resync
432-
func (auth *Authenticator) UpdateSequenceNumber(p Principal, seq uint64) error {
431+
// Used for resync. Cancels update if provided resyncID matches existing on the principal
432+
func (auth *Authenticator) UpdateSequenceNumberForResync(p Principal, seq uint64, resyncID string) error {
433+
434+
if resyncID == "" {
435+
return errors.New("resyncID must not be empty")
436+
}
437+
if p.ResyncID() == resyncID {
438+
return nil
439+
}
433440
p.SetSequence(seq)
441+
p.SetResyncID(resyncID)
434442
casOut, writeErr := auth.datastore.WriteCas(auth.LogCtx, p.DocID(), 0, p.Cas(), p, 0)
435443
if writeErr != nil {
436444
return writeErr

0 commit comments

Comments
 (0)