Merge pull request #1126 from restic/switch-to-default-go-git-layout

Use idiomatic default Go git repo layout
This commit is contained in:
Alexander Neumann 2017-07-23 16:54:53 +02:00
commit f63d7de9da
1988 changed files with 216488 additions and 3295 deletions

1
.envrc
View File

@ -1 +0,0 @@
GOPATH=$PWD:$PWD/vendor

3
.gitignore vendored
View File

@ -1,6 +1,3 @@
/pkg
/bin
/restic
/.vagrant
/vendor/pkg
/doc/_build

View File

@ -60,50 +60,35 @@ uploading it somewhere or post only the parts that are really relevant.
Development Environment
=======================
For development you need the build tool [`gb`](https://getgb.io), it can be
installed by running the following command:
In order to compile restic with the `go` tool directly, it needs to be checked
out at the right path within a `GOPATH`. The concept of a `GOPATH` is explained
in ["How to write Go code"](https://golang.org/doc/code.html).
$ go get github.com/constabulary/gb/...
The repository contains two directories with code: `src/` contains the code
written for restic, whereas `vendor/` contains copies of libraries restic
depends on. The libraries are managed with the `gb vendor` command.
Just clone the repository, `cd` to it and run `gb build` to build the binary:
If you do not have a directory with Go code yet, executing the following
instructions in your shell will create one for you and check out the restic
repo:
$ export GOPATH="$HOME/go"
$ mkdir -p "$GOPATH/src/github.com/restic"
$ cd "$GOPATH/src/github.com/restic"
$ git clone https://github.com/restic/restic
$ cd restic
$ gb build
[...]
$ bin/restic version
You can then build restic as follows:
$ go build ./cmd/restic
$ ./restic version
restic compiled manually
compiled at unknown time with go1.7
compiled with go1.8.3 on linux/amd64
The following commands can be used to run all the tests:
$ gb test
ok github.com/restic/restic 8.174s
[...]
$ go test ./cmd/... ./internal/...
If you want to run your tests on Linux, OpenBSD or FreeBSD, you can use
[vagrant](https://www.vagrantup.com/) with the provided `Vagrantfile` to
quickly set up VMs and run the tests, e.g.:
$ vagrant up freebsd
[...]
$ vagrant ssh freebsd -c 'cd restic/restic; go test -v ./...'
[...]
The default `go` tool can also be used by setting the environment variable
`GOPATH` to the following value while being in the top level directory in the
git repository:
$ export GOPATH=$PWD:$PWD/vendor
The file `.envrc` allows automatic `GOPATH` configuration with
[direnv](https://direnv.net/), inspect the file and then allow automatic
configuration by running `direnv allow`.
The repository contains two sets of directories with code: `cmd/` and
`internal/` contain the code written for restic, whereas `vendor/` contains
copies of libraries restic depends on. The libraries are managed with the
[`dep`](https://github.com/golang/dep) tool.
Providing Patches
=================
@ -122,7 +107,8 @@ down to the following steps:
2. Clone the repository locally and create a new branch. If you are working on
the code itself, please set up the development environment as described in
the previous section.
the previous section. Especially take care to place your forked repository
at the correct path (`src/github.com/restic/restic`) within your `GOPATH`.
3. Then commit your changes as fine grained as possible, as smaller patches,
that handle one and only one issue are easier to discuss and merge.

View File

@ -1,57 +0,0 @@
# This Dockerfiles configures a container that is similar to the Travis CI
# environment and can be used to run tests locally.
#
# build the image:
# docker build -t restic/test .
#
# run all tests and cross-compile restic:
# docker run --rm -v $PWD:/home/travis/restic restic/test go run run_integration_tests.go -minio minio
#
# run interactively:
# docker run --interactive --tty --rm -v $PWD:/home/travis/restic restic/test /bin/bash
#
# run a subset of tests:
# docker run --rm -v $PWD:/home/travis/restic restic/test gb test -v ./backend
#
# build the image for an older version of Go:
# docker build --build-arg GOVERSION=1.6.4 -t restic/test:go1.6.4 .
FROM ubuntu:14.04
ARG GOVERSION=1.8.3
ARG GOARCH=amd64
# install dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends ca-certificates wget git build-essential openssh-server
# add and configure user
ENV HOME /home/travis
RUN useradd -m -d $HOME -s /bin/bash travis
# run everything below as user travis
USER travis
WORKDIR $HOME
# download and install Go
RUN wget -q -O /tmp/go.tar.gz https://storage.googleapis.com/golang/go${GOVERSION}.linux-${GOARCH}.tar.gz
RUN tar xf /tmp/go.tar.gz && rm -f /tmp/go.tar.gz
ENV GOROOT $HOME/go
ENV GOPATH $HOME/gopath
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin:$HOME/bin
RUN mkdir -p $HOME/restic
# pre-install tools, this speeds up running the tests itself
RUN go get github.com/constabulary/gb/...
RUN go get golang.org/x/tools/cmd/cover
RUN go get github.com/mitchellh/gox
RUN go get github.com/pierrre/gotestcover
RUN mkdir $HOME/bin \
&& wget -q -O $HOME/bin/minio https://dl.minio.io/server/minio/release/linux-${GOARCH}/minio \
&& chmod +x $HOME/bin/minio
# set TRAVIS_BUILD_DIR for integration script
ENV TRAVIS_BUILD_DIR $HOME/restic
WORKDIR $HOME/restic

123
Gopkg.lock generated Normal file
View File

@ -0,0 +1,123 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "master"
name = "bazil.org/fuse"
packages = [".","fs","fuseutil"]
revision = "371fbbdaa8987b715bdd21d6adc4c9b20155f748"
[[projects]]
name = "github.com/elithrar/simple-scrypt"
packages = ["."]
revision = "47767683c6c880a9f89e48d376c70de7f5268951"
version = "v1.1"
[[projects]]
name = "github.com/go-ini/ini"
packages = ["."]
revision = "d3de07a94d22b4a0972deb4b96d790c2c0ce8333"
version = "v1.28.0"
[[projects]]
branch = "master"
name = "github.com/inconshreveable/mousetrap"
packages = ["."]
revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
[[projects]]
branch = "master"
name = "github.com/kr/fs"
packages = ["."]
revision = "2788f0dbd16903de03cb8186e5c7d97b69ad387b"
[[projects]]
name = "github.com/kurin/blazer"
packages = ["b2","base","internal/b2types","internal/blog"]
revision = "612082ed2430716569f1ec816fc6ade849020816"
version = "v0.1.0"
[[projects]]
branch = "master"
name = "github.com/minio/go-homedir"
packages = ["."]
revision = "21304a94172ae3a09dee2cd86a12fb6f842138c7"
[[projects]]
name = "github.com/minio/minio-go"
packages = [".","pkg/credentials","pkg/encrypt","pkg/policy","pkg/s3signer","pkg/s3utils","pkg/set"]
revision = "5ca66c9a35ba1cd674484be99dc97aa0973afe12"
version = "v3.0.0"
[[projects]]
branch = "master"
name = "github.com/ncw/swift"
packages = ["."]
revision = "5068c3506cf003c630c94b92a64e978115394f26"
[[projects]]
name = "github.com/pkg/errors"
packages = ["."]
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
version = "v0.8.0"
[[projects]]
name = "github.com/pkg/profile"
packages = ["."]
revision = "5b67d428864e92711fcbd2f8629456121a56d91f"
version = "v1.2.1"
[[projects]]
branch = "master"
name = "github.com/pkg/sftp"
packages = ["."]
revision = "4f3e725e885c021085d2fb8a9cc26e30ea1a992f"
[[projects]]
name = "github.com/pkg/xattr"
packages = ["."]
revision = "23c75e3f6c1d8b13b3dd905b011a7f38a06044b7"
version = "v0.2.1"
[[projects]]
name = "github.com/restic/chunker"
packages = ["."]
revision = "bb2ecf9a98e35a0b336ffc23fc515fb6e7961577"
version = "v0.1.0"
[[projects]]
branch = "master"
name = "github.com/spf13/cobra"
packages = ["."]
revision = "f20b4e9c32bb3e9d44773ca208db814f24dcd21b"
[[projects]]
name = "github.com/spf13/pflag"
packages = ["."]
revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66"
version = "v1.0.0"
[[projects]]
branch = "master"
name = "golang.org/x/crypto"
packages = ["curve25519","ed25519","ed25519/internal/edwards25519","pbkdf2","poly1305","scrypt","ssh","ssh/terminal"]
revision = "6914964337150723782436d56b3f21610a74ce7b"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = ["context","context/ctxhttp"]
revision = "ab5485076ff3407ad2d02db054635913f017b0ed"
[[projects]]
branch = "master"
name = "golang.org/x/sys"
packages = ["unix"]
revision = "c4489faa6e5ab84c0ef40d6ee878f7a030281f0f"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "b4de858790fd06b6d1df19baa8a3246f23b2fded9ab6eb85325ddb3ee91003b8"
solver-name = "gps-cdcl"
solver-version = 1

78
Gopkg.toml Normal file
View File

@ -0,0 +1,78 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[[constraint]]
branch = "master"
name = "bazil.org/fuse"
[[constraint]]
name = "github.com/elithrar/simple-scrypt"
version = "1.1.0"
[[constraint]]
name = "github.com/kurin/blazer"
version = "0.1.0"
[[constraint]]
name = "github.com/minio/minio-go"
version = "3.0.0"
[[constraint]]
branch = "master"
name = "github.com/ncw/swift"
[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"
[[constraint]]
name = "github.com/pkg/profile"
version = "1.2.1"
[[constraint]]
branch = "master"
name = "github.com/pkg/sftp"
[[constraint]]
name = "github.com/pkg/xattr"
version = "0.2.1"
[[constraint]]
name = "github.com/restic/chunker"
version = "0.1.0"
[[constraint]]
branch = "master"
name = "github.com/spf13/cobra"
[[constraint]]
branch = "master"
name = "golang.org/x/crypto"
[[constraint]]
branch = "master"
name = "golang.org/x/net"
[[constraint]]
branch = "master"
name = "golang.org/x/sys"

View File

@ -6,7 +6,7 @@ restic:
go run build.go
clean:
rm -rf restic
rm -f restic
test:
go test ./...
go test ./cmd/... ./internal/...

124
Vagrantfile vendored
View File

@ -1,124 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
GO_VERSION = '1.7'
def packages_freebsd
return <<-EOF
pkg install -y git
pkg install -y curl
echo 'fuse_load="YES"' >> /boot/loader.conf
echo 'vfs.usermount=1' >> /etc/sysctl.conf
kldload fuse
sysctl vfs.usermount=1
pw groupmod operator -M vagrant
EOF
end
def packages_openbsd
return <<-EOF
. ~/.profile
pkg_add git curl bash gtar--
ln -sf /usr/local/bin/gtar /usr/local/bin/tar
EOF
end
def packages_linux
return <<-EOF
apt-get update
apt-get install -y git curl
EOF
end
def packages_darwin
return <<-EOF
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew cask install osxfuse
EOF
end
def install_gimme
return <<-EOF
rm -rf /opt/gimme
mkdir -p /opt/gimme || true
git clone https://github.com/meatballhat/gimme /opt/gimme
perl -p -i -e 's,/bin/bash,/usr/bin/env bash,' /opt/gimme/gimme
ln -sf /opt/gimme/gimme /usr/bin/gimme
EOF
end
def prepare_user(boxname)
return <<-EOF
mkdir -p ~/go/src
export PATH=/usr/local/bin:$PATH
gimme #{GO_VERSION} >> ~/.profile
echo export 'GOPATH=/vagrant/go' >> ~/.profile
echo export 'PATH=$GOPATH/bin:/usr/local/bin:$PATH' >> ~/.profile
. ~/.profile
go get golang.org/x/tools/cmd/cover
go get github.com/constabulary/gb/...
echo
echo "Run:"
echo " vagrant rsync #{boxname}"
echo " vagrant ssh #{boxname} -c 'cd /vagrant; gb build && gb test'"
EOF
end
def fix_perms
return <<-EOF
chown -R vagrant /vagrant
EOF
end
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# use rsync to copy content to the folder
config.vm.synced_folder ".", "/vagrant", :type => "rsync"
# fix permissions on synced folder
config.vm.provision "fix perms", :type => :shell, :inline => fix_perms
config.vm.define "linux" do |b|
b.vm.box = "ubuntu/trusty64"
b.vm.provision "packages linux", :type => :shell, :inline => packages_linux
b.vm.provision "install gimme", :type => :shell, :inline => install_gimme
b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("linux")
# fix network card
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--nictype1", "virtio"]
end
end
config.vm.define "freebsd" do |b|
b.vm.box = "geoffgarside/freebsd-10.1"
b.vm.provision "packages freebsd", :type => :shell, :inline => packages_freebsd
b.vm.provision "install gimme", :type => :shell, :inline => install_gimme
b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("freebsd")
end
config.vm.define "openbsd" do |b|
b.vm.box = "tmatilai/openbsd-5.6"
b.vm.provision "packages openbsd", :type => :shell, :inline => packages_openbsd
b.vm.provision "install gimme", :type => :shell, :inline => install_gimme
b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("openbsd")
end
config.vm.define "darwin" do |b|
#b.vm.box = "jhcook/osx-yosemite-10.10"
b.vm.box = "jhcook/yosemite-clitools"
b.vm.provision "packages darwin", :type => :shell, :privileged => false, :inline => packages_darwin
b.vm.provision "install gimme", :type => :shell, :inline => install_gimme
b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("darwin")
end
end

View File

@ -27,10 +27,12 @@ var config = struct {
Main string
Tests []string
}{
Name: "restic", // name of the program executable and directory
Namespace: "", // subdir of GOPATH, e.g. "github.com/foo/bar"
Main: "cmds/restic", // package name for the main package
Tests: []string{"restic/...", "cmds/..."}, // tests to run
Name: "restic", // name of the program executable and directory
Namespace: "github.com/restic/restic", // subdir of GOPATH, e.g. "github.com/foo/bar"
Main: "github.com/restic/restic/cmd/restic", // package name for the main package
Tests: []string{ // tests to run
"github.com/restic/restic/internal/...",
"github.com/restic/restic/cmd/..."},
}
// specialDir returns true if the file begins with a special character ('.' or '_').
@ -77,7 +79,12 @@ func excludePath(name string) bool {
// └── restic
// └── foo.go
func updateGopath(dst, src, prefix string) error {
verbosePrintf("copy contents of %v to %v\n", src, filepath.Join(dst, prefix))
return filepath.Walk(src, func(name string, fi os.FileInfo, err error) error {
if name == src {
return err
}
if specialDir(name) {
if fi.IsDir() {
return filepath.SkipDir
@ -86,6 +93,10 @@ func updateGopath(dst, src, prefix string) error {
return nil
}
if err != nil {
return err
}
if fi.IsDir() {
return nil
}
@ -368,13 +379,13 @@ func main() {
}
verbosePrintf("create GOPATH at %v\n", gopath)
if err = updateGopath(gopath, filepath.Join(root, "src"), config.Namespace); err != nil {
if err = updateGopath(gopath, root, config.Namespace); err != nil {
die("copying files from %v/src to %v/src failed: %v\n", root, gopath, err)
}
vendor := filepath.Join(root, "vendor", "src")
vendor := filepath.Join(root, "vendor")
if directoryExists(vendor) {
if err = updateGopath(gopath, vendor, ""); err != nil {
if err = updateGopath(gopath, vendor, filepath.Join(config.Namespace, "vendor")); err != nil {
die("copying files from %v to %v failed: %v\n", root, gopath, err)
}
}

View File

@ -4,7 +4,7 @@ import (
"syscall"
"unsafe"
"restic/debug"
"github.com/restic/restic/internal/debug"
)
// IsProcessBackground returns true if it is running in the background or false if not

View File

@ -7,7 +7,7 @@ import (
"sync"
"syscall"
"restic/debug"
"github.com/restic/restic/internal/debug"
)
var cleanupHandlers struct {

View File

@ -7,17 +7,18 @@ import (
"io"
"os"
"path/filepath"
"restic"
"strings"
"time"
"github.com/restic/restic/internal"
"github.com/spf13/cobra"
"restic/archiver"
"restic/debug"
"restic/errors"
"restic/filter"
"restic/fs"
"github.com/restic/restic/internal/archiver"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/filter"
"github.com/restic/restic/internal/fs"
)
var cmdBackup = &cobra.Command{

View File

@ -8,10 +8,10 @@ import (
"github.com/spf13/cobra"
"restic"
"restic/backend"
"restic/errors"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
)
var cmdCat = &cobra.Command{

View File

@ -8,9 +8,9 @@ import (
"github.com/spf13/cobra"
"restic"
"restic/checker"
"restic/errors"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/checker"
"github.com/restic/restic/internal/errors"
)
var cmdCheck = &cobra.Command{

View File

@ -11,12 +11,12 @@ import (
"github.com/spf13/cobra"
"restic"
"restic/errors"
"restic/pack"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/pack"
"github.com/restic/restic/internal/repository"
"restic/worker"
"github.com/restic/restic/internal/worker"
)
var cmdDump = &cobra.Command{

View File

@ -9,9 +9,9 @@ import (
"github.com/spf13/cobra"
"restic"
"restic/debug"
"restic/errors"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
)
var cmdFind = &cobra.Command{

View File

@ -3,10 +3,11 @@ package main
import (
"context"
"encoding/json"
"restic"
"sort"
"strings"
"github.com/restic/restic/internal"
"github.com/spf13/cobra"
)

View File

@ -2,8 +2,9 @@ package main
import (
"context"
"restic/errors"
"restic/repository"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
"github.com/spf13/cobra"
)

View File

@ -3,9 +3,10 @@ package main
import (
"context"
"fmt"
"restic"
"restic/errors"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
"github.com/spf13/cobra"
)

View File

@ -3,9 +3,10 @@ package main
import (
"context"
"fmt"
"restic"
"restic/errors"
"restic/index"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/index"
"github.com/spf13/cobra"
)

View File

@ -6,9 +6,9 @@ import (
"github.com/spf13/cobra"
"restic"
"restic/errors"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
)
var cmdLs = &cobra.Command{

View File

@ -1,8 +1,8 @@
package main
import (
"restic"
"restic/migrations"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/migrations"
"github.com/spf13/cobra"
)

View File

@ -6,15 +6,16 @@ package main
import (
"context"
"os"
"restic"
"github.com/restic/restic/internal"
"github.com/spf13/cobra"
"restic/debug"
"restic/errors"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
resticfs "restic/fs"
"restic/fuse"
resticfs "github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/fuse"
systemFuse "bazil.org/fuse"
"bazil.org/fuse/fs"

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"restic/options"
"github.com/restic/restic/internal/options"
"github.com/spf13/cobra"
)

View File

@ -2,13 +2,14 @@ package main
import (
"fmt"
"restic"
"restic/debug"
"restic/errors"
"restic/index"
"restic/repository"
"time"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/index"
"github.com/restic/restic/internal/repository"
"github.com/spf13/cobra"
)

View File

@ -2,8 +2,9 @@ package main
import (
"context"
"restic"
"restic/index"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/index"
"github.com/spf13/cobra"
)

View File

@ -1,10 +1,10 @@
package main
import (
"restic"
"restic/debug"
"restic/errors"
"restic/filter"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/filter"
"github.com/spf13/cobra"
)

View File

@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
"restic"
"github.com/restic/restic/internal"
)
var cmdSnapshots = &cobra.Command{

View File

@ -5,10 +5,10 @@ import (
"github.com/spf13/cobra"
"restic"
"restic/debug"
"restic/errors"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
)
var cmdTag = &cobra.Command{

View File

@ -2,7 +2,8 @@ package main
import (
"context"
"restic"
"github.com/restic/restic/internal"
"github.com/spf13/cobra"
)

View File

@ -3,8 +3,8 @@ package main
import (
"context"
"restic"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/repository"
)
// FindFilteredSnapshots yields Snapshots, either given explicitly by `snapshotIDs` or filtered from the list of all snapshots.

View File

@ -6,7 +6,7 @@ import (
"path/filepath"
"time"
"restic"
"github.com/restic/restic/internal"
)
func formatBytes(c uint64) string {

View File

@ -6,23 +6,24 @@ import (
"io"
"io/ioutil"
"os"
"restic"
"runtime"
"strings"
"syscall"
"restic/backend/b2"
"restic/backend/local"
"restic/backend/location"
"restic/backend/rest"
"restic/backend/s3"
"restic/backend/sftp"
"restic/backend/swift"
"restic/debug"
"restic/options"
"restic/repository"
"github.com/restic/restic/internal"
"restic/errors"
"github.com/restic/restic/internal/backend/b2"
"github.com/restic/restic/internal/backend/local"
"github.com/restic/restic/internal/backend/location"
"github.com/restic/restic/internal/backend/rest"
"github.com/restic/restic/internal/backend/s3"
"github.com/restic/restic/internal/backend/sftp"
"github.com/restic/restic/internal/backend/swift"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/options"
"github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/errors"
"golang.org/x/crypto/ssh/terminal"
)

View File

@ -7,8 +7,9 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"restic/errors"
"restic/repository"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
"github.com/pkg/profile"
)

View File

@ -12,9 +12,9 @@ import (
"testing"
"time"
"restic"
"restic/repository"
. "restic/test"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/repository"
. "github.com/restic/restic/internal/test"
)
const (

View File

@ -9,9 +9,9 @@ import (
"runtime"
"testing"
"restic/options"
"restic/repository"
. "restic/test"
"github.com/restic/restic/internal/options"
"github.com/restic/restic/internal/repository"
. "github.com/restic/restic/internal/test"
)
type dirEntry struct {

View File

@ -12,18 +12,19 @@ import (
"os"
"path/filepath"
"regexp"
"restic"
"strings"
"syscall"
"testing"
"time"
"restic/errors"
"github.com/restic/restic/internal"
"restic/debug"
"restic/filter"
"restic/repository"
. "restic/test"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/filter"
"github.com/restic/restic/internal/repository"
. "github.com/restic/restic/internal/test"
)
func parseIDsFromReader(t testing.TB, rd io.Reader) restic.IDs {
@ -1099,7 +1100,7 @@ func TestFindJSON(t *testing.T) {
func TestRebuildIndex(t *testing.T) {
withTestEnvironment(t, func(env *testEnvironment, gopts GlobalOptions) {
datafile := filepath.Join("..", "..", "restic", "checker", "testdata", "duplicate-packs-in-index-test-repo.tar.gz")
datafile := filepath.Join("..", "..", "internal", "checker", "testdata", "duplicate-packs-in-index-test-repo.tar.gz")
SetupTarTestFixture(t, env.base, datafile)
out, err := testRunCheckOutput(gopts)

View File

@ -2,8 +2,9 @@ package main
import (
"path/filepath"
. "restic/test"
"testing"
. "github.com/restic/restic/internal/test"
)
func TestRestoreLocalLayout(t *testing.T) {
@ -19,7 +20,7 @@ func TestRestoreLocalLayout(t *testing.T) {
}
for _, test := range tests {
datafile := filepath.Join("..", "..", "restic", "backend", "testdata", test.filename)
datafile := filepath.Join("..", "..", "internal", "backend", "testdata", test.filename)
SetupTarTestFixture(t, env.base, datafile)

View File

@ -7,9 +7,9 @@ import (
"sync"
"time"
"restic"
"restic/debug"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/repository"
)
var globalLocks struct {

View File

@ -6,14 +6,15 @@ import (
"fmt"
"log"
"os"
"restic"
"restic/debug"
"restic/options"
"runtime"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/options"
"github.com/spf13/cobra"
"restic/errors"
"github.com/restic/restic/internal/errors"
)
// cmdRoot is the base command when no other command has been specified.

View File

@ -3,11 +3,12 @@ package archiver
import (
"context"
"io"
"restic"
"restic/debug"
"time"
"restic/errors"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/chunker"
)

View File

@ -6,10 +6,11 @@ import (
"errors"
"io"
"math/rand"
"restic"
"restic/checker"
"restic/repository"
"testing"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/checker"
"github.com/restic/restic/internal/repository"
)
func loadBlob(t *testing.T, repo restic.Repository, id restic.ID, buf []byte) int {

View File

@ -7,17 +7,18 @@ import (
"io"
"os"
"path/filepath"
"restic"
"sort"
"sync"
"time"
"restic/errors"
"restic/walk"
"github.com/restic/restic/internal"
"restic/debug"
"restic/fs"
"restic/pipe"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/walk"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/pipe"
"github.com/restic/chunker"
)

View File

@ -9,12 +9,12 @@ import (
"testing"
"time"
"restic/errors"
"github.com/restic/restic/internal/errors"
"restic"
"restic/archiver"
"restic/mock"
"restic/repository"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/archiver"
"github.com/restic/restic/internal/mock"
"github.com/restic/restic/internal/repository"
)
const parallelSaves = 50

View File

@ -5,8 +5,8 @@ import (
"os"
"testing"
"restic/pipe"
"restic/walk"
"github.com/restic/restic/internal/pipe"
"github.com/restic/restic/internal/walk"
)
var treeJobs = []string{

View File

@ -7,14 +7,14 @@ import (
"testing"
"time"
"restic"
"restic/archiver"
"restic/checker"
"restic/crypto"
"restic/repository"
. "restic/test"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/archiver"
"github.com/restic/restic/internal/checker"
"github.com/restic/restic/internal/crypto"
"github.com/restic/restic/internal/repository"
. "github.com/restic/restic/internal/test"
"restic/errors"
"github.com/restic/restic/internal/errors"
"github.com/restic/chunker"
)

View File

@ -2,8 +2,9 @@ package archiver
import (
"context"
"restic"
"testing"
"github.com/restic/restic/internal"
)
// TestSnapshot creates a new snapshot of path.

View File

@ -4,12 +4,13 @@ import (
"context"
"io"
"path"
"restic"
"strings"
"restic/backend"
"restic/debug"
"restic/errors"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/kurin/blazer/b2"
)

View File

@ -7,11 +7,11 @@ import (
"testing"
"time"
"restic"
"restic/backend/b2"
"restic/backend/test"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/backend/b2"
"github.com/restic/restic/internal/backend/test"
. "restic/test"
. "github.com/restic/restic/internal/test"
)
func newB2TestSuite(t testing.TB) *test.Suite {

View File

@ -5,8 +5,8 @@ import (
"regexp"
"strings"
"restic/errors"
"restic/options"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/options"
)
// Config contains all configuration necessary to connect to an b2 compatible

View File

@ -3,8 +3,9 @@ package backend
import (
"net"
"net/http"
"restic/debug"
"time"
"github.com/restic/restic/internal/debug"
)
// Transport returns a new http.RoundTripper with default settings applied.

View File

@ -5,10 +5,11 @@ import (
"os"
"path/filepath"
"regexp"
"restic"
"restic/debug"
"restic/errors"
"restic/fs"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/fs"
)
// Layout computes paths for file name storage.

View File

@ -2,7 +2,8 @@ package backend
import (
"encoding/hex"
"restic"
"github.com/restic/restic/internal"
)
// DefaultLayout implements the default layout for local and sftp backends, as

View File

@ -1,6 +1,6 @@
package backend
import "restic"
import "github.com/restic/restic/internal"
// RESTLayout implements the default layout for the REST protocol.
type RESTLayout struct {

View File

@ -1,6 +1,6 @@
package backend
import "restic"
import "github.com/restic/restic/internal"
// S3LegacyLayout implements the old layout used for s3 cloud storage backends, as
// described in the Design document.

View File

@ -5,10 +5,11 @@ import (
"path"
"path/filepath"
"reflect"
"restic"
. "restic/test"
"sort"
"testing"
"github.com/restic/restic/internal"
. "github.com/restic/restic/internal/test"
)
func TestDefaultLayout(t *testing.T) {

View File

@ -3,8 +3,8 @@ package local
import (
"strings"
"restic/errors"
"restic/options"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/options"
)
// Config holds all information needed to open a local repository.

View File

@ -3,9 +3,10 @@ package local
import (
"context"
"path/filepath"
"restic"
. "restic/test"
"testing"
"github.com/restic/restic/internal"
. "github.com/restic/restic/internal/test"
)
func TestLayout(t *testing.T) {

View File

@ -5,13 +5,14 @@ import (
"io"
"os"
"path/filepath"
"restic"
"restic/errors"
"github.com/restic/restic/internal"
"restic/backend"
"restic/debug"
"restic/fs"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/fs"
)
// Local is a backend in a local directory.

View File

@ -2,12 +2,13 @@ package local_test
import (
"io/ioutil"
"restic"
"testing"
"restic/backend/local"
"restic/backend/test"
. "restic/test"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/backend/local"
"github.com/restic/restic/internal/backend/test"
. "github.com/restic/restic/internal/test"
)
func newTestSuite(t testing.TB) *test.Suite {

View File

@ -4,7 +4,8 @@ package local
import (
"os"
"restic/fs"
"github.com/restic/restic/internal/fs"
)
// set file to readonly

View File

@ -4,13 +4,13 @@ package location
import (
"strings"
"restic/backend/b2"
"restic/backend/local"
"restic/backend/rest"
"restic/backend/s3"
"restic/backend/sftp"
"restic/backend/swift"
"restic/errors"
"github.com/restic/restic/internal/backend/b2"
"github.com/restic/restic/internal/backend/local"
"github.com/restic/restic/internal/backend/rest"
"github.com/restic/restic/internal/backend/s3"
"github.com/restic/restic/internal/backend/sftp"
"github.com/restic/restic/internal/backend/swift"
"github.com/restic/restic/internal/errors"
)
// Location specifies the location of a repository, including the method of

View File

@ -5,12 +5,12 @@ import (
"reflect"
"testing"
"restic/backend/b2"
"restic/backend/local"
"restic/backend/rest"
"restic/backend/s3"
"restic/backend/sftp"
"restic/backend/swift"
"github.com/restic/restic/internal/backend/b2"
"github.com/restic/restic/internal/backend/local"
"github.com/restic/restic/internal/backend/rest"
"github.com/restic/restic/internal/backend/s3"
"github.com/restic/restic/internal/backend/sftp"
"github.com/restic/restic/internal/backend/swift"
)
func parseURL(s string) *url.URL {

View File

@ -5,12 +5,13 @@ import (
"context"
"io"
"io/ioutil"
"restic"
"sync"
"restic/errors"
"github.com/restic/restic/internal"
"restic/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/debug"
)
type memMap map[restic.Handle][]byte

View File

@ -2,13 +2,14 @@ package mem_test
import (
"context"
"restic"
"testing"
"restic/errors"
"github.com/restic/restic/internal"
"restic/backend/mem"
"restic/backend/test"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/backend/mem"
"github.com/restic/restic/internal/backend/test"
)
type memConfig struct {

View File

@ -4,8 +4,8 @@ import (
"net/url"
"strings"
"restic/errors"
"restic/options"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/options"
)
// Config contains all configuration necessary to connect to a REST server.

View File

@ -9,15 +9,16 @@ import (
"net/http"
"net/url"
"path"
"restic"
"strings"
"github.com/restic/restic/internal"
"golang.org/x/net/context/ctxhttp"
"restic/debug"
"restic/errors"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"restic/backend"
"github.com/restic/restic/internal/backend"
)
// make sure the rest backend implements restic.Backend

View File

@ -7,13 +7,14 @@ import (
"net/url"
"os"
"os/exec"
"restic"
"testing"
"time"
"restic/backend/rest"
"restic/backend/test"
. "restic/test"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/backend/rest"
"github.com/restic/restic/internal/backend/test"
. "github.com/restic/restic/internal/test"
)
func runRESTServer(ctx context.Context, t testing.TB, dir string) func() {

View File

@ -5,8 +5,8 @@ import (
"path"
"strings"
"restic/errors"
"restic/options"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/options"
)
// Config contains all configuration necessary to connect to an s3 compatible

View File

@ -7,17 +7,18 @@ import (
"io/ioutil"
"os"
"path"
"restic"
"strings"
"time"
"restic/backend"
"restic/errors"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/errors"
"github.com/minio/minio-go"
"github.com/minio/minio-go/pkg/credentials"
"restic/debug"
"github.com/restic/restic/internal/debug"
)
// Backend stores data on an S3 endpoint.

View File

@ -11,13 +11,14 @@ import (
"os"
"os/exec"
"path/filepath"
"restic"
"testing"
"time"
"restic/backend/s3"
"restic/backend/test"
. "restic/test"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/backend/s3"
"github.com/restic/restic/internal/backend/test"
. "github.com/restic/restic/internal/test"
)
func mkdir(t testing.TB, dir string) {

View File

@ -1,6 +1,6 @@
package backend
import "restic/errors"
import "github.com/restic/restic/internal/errors"
// Semaphore limits access to a restricted resource.
type Semaphore struct {

View File

@ -5,8 +5,8 @@ import (
"path"
"strings"
"restic/errors"
"restic/options"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/options"
)
// Config collects all information required to connect to an sftp server.

Some files were not shown because too many files have changed in this diff Show More