Skip to content

Commit

Permalink
Update restic to v0.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CGamesPlay committed Jan 14, 2023
1 parent edea358 commit f4339f1
Show file tree
Hide file tree
Showing 12 changed files with 819 additions and 665 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This program is based on a fork of restic and may not be up-to-date with the lat
>
> During initial development (versions prior to 1.0.0), maintainers and developers will do their utmost to keep backwards compatibility and stability, although there might be breaking changes without increasing the major version.
The latest version of this software is based on restic 0.14.0. The currently installed version can be checked by running `git-remote-restic --version`.
The latest version of this software is based on restic 0.15.0. The currently installed version can be checked by running `git-remote-restic --version`.

Bug reports are accepted.

Expand Down
4 changes: 2 additions & 2 deletions cmd/git-remote-restic/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ func (r *Repository) Git(allowInit bool) (*git.Repository, error) {
var err error
if r.fs == nil {
var parentSnapshot *restic.ID
id, err := restic.FindLatestSnapshot(context.Background(), r.restic.Backend(), r.restic, []string{}, []restic.TagList{}, []string{}, nil)
sn, err := restic.FindFilteredSnapshot(context.Background(), r.restic.Backend(), r.restic, nil, nil, nil, nil, "latest")
if err != nil && err != restic.ErrNoSnapshotFound {
return nil, err
}
if err == nil {
parentSnapshot = &id
parentSnapshot = sn.ID()
}
r.fs, err = resticfs.New(context.Background(), r.restic, parentSnapshot)
if err != nil {
Expand Down
19 changes: 9 additions & 10 deletions cmd/git-remote-restic/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"os"
"time"

"github.com/restic/restic/lib/backend"
"github.com/restic/restic/lib/backend/azure"
Expand Down Expand Up @@ -182,14 +181,13 @@ func openResticBackend(ctx context.Context, s string, opts options.Options) (res
return nil, err
}

tropts := backend.TransportOptions{}
rt, err := backend.Transport(tropts)
rt, err := backend.Transport(backend.TransportOptions{})
if err != nil {
return nil, err
}

// wrap the transport so that the throughput via HTTP is limited
lim := limiter.NewStaticLimiter(limiter.Limits{0, 0})
lim := limiter.NewStaticLimiter(limiter.Limits{UploadKb: 0, DownloadKb: 0})
rt = lim.Transport(rt)

switch loc.Scheme {
Expand All @@ -202,7 +200,7 @@ func openResticBackend(ctx context.Context, s string, opts options.Options) (res
case "gs":
be, err = gs.Open(cfg.(gs.Config), rt)
case "azure":
be, err = azure.Open(cfg.(azure.Config), rt)
be, err = azure.Open(ctx, cfg.(azure.Config), rt)
case "swift":
be, err = swift.Open(ctx, cfg.(swift.Config), rt)
case "b2":
Expand All @@ -217,7 +215,12 @@ func openResticBackend(ctx context.Context, s string, opts options.Options) (res
}

if err != nil {
return nil, errors.Fatalf("unable to open repo at %v: %v", location.StripPassword(s), err)
return nil, errors.Fatalf("unable to open repository at %v: %v", location.StripPassword(s), err)
}

if loc.Scheme == "local" || loc.Scheme == "sftp" {
// wrap the backend in a LimitBackend so that the throughput is limited
be = limiter.LimitBackend(be, lim)
}

// check if config is there
Expand All @@ -230,9 +233,5 @@ func openResticBackend(ctx context.Context, s string, opts options.Options) (res
return nil, errors.New("config file has zero size, invalid repository?")
}

be = backend.NewRetryBackend(be, 10, func(msg string, err error, d time.Duration) {
Warnf("%v returned error, retrying after %v: %v\n", msg, d, err)
})

return be, nil
}
14 changes: 14 additions & 0 deletions doc/MAINTENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Maintenance

## Upgrading the restic version

1. Use `./scripts/update-restic.sh` to update the submodule. It automatically pushes a modified tag to the custom restic fork on Github.
2. Update the README.
3. Use `go mod tidy` to fetch all the modules and remove the unused ones.
4. Use `./scripts/update-cmd.sh` to update the repository opening code.
- If the patch fails, use `diff -u restic/cmd/restic/global.go cmd/git-remote-restic/restic.go > scripts/update-cmd.patch` to update it.
5. Use `make test` to verify everything still works.
- Use `git log -pG <pattern>` to identify commits that changed APIs that are now broken.
6. Make a commit.
7. Use `make release` to compile a new release.
8. Push everything to Github, and make a new release there.
69 changes: 66 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/CGamesPlay/git-remote-restic

go 1.13
go 1.18

replace github.com/restic/restic => ./restic

Expand All @@ -12,7 +12,70 @@ require (
github.com/pkg/errors v0.9.1
github.com/restic/chunker v0.4.0
github.com/restic/restic v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.7.0
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde
github.com/stretchr/testify v1.8.1
golang.org/x/sync v0.1.0
)

require (
cloud.google.com/go v0.108.0 // indirect
cloud.google.com/go/compute v1.15.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.10.0 // indirect
cloud.google.com/go/storage v1.28.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/elithrar/simple-scrypt v1.3.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/juju/ratelimit v1.0.2 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/klauspost/compress v1.15.14 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kurin/blazer v0.5.4-0.20211030221322-ba894c124ac6 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.46 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncw/swift/v2 v2.0.1 // indirect
github.com/pkg/sftp v1.13.5 // indirect
github.com/pkg/xattr v0.4.10-0.20221120235825-35026bbbd013 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.4.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/xanzy/ssh-agent v0.2.1 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.106.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.52.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit f4339f1

Please sign in to comment.