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
1988 changed files with 216488 additions and 3295 deletions
-1
View File
@@ -1 +0,0 @@
GOPATH=$PWD:$PWD/vendor
-3
View File
@@ -1,6 +1,3 @@
/pkg
/bin
/restic /restic
/.vagrant /.vagrant
/vendor/pkg
/doc/_build /doc/_build
+22 -36
View File
@@ -60,50 +60,35 @@ uploading it somewhere or post only the parts that are really relevant.
Development Environment Development Environment
======================= =======================
For development you need the build tool [`gb`](https://getgb.io), it can be In order to compile restic with the `go` tool directly, it needs to be checked
installed by running the following command: 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/... 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
The repository contains two directories with code: `src/` contains the code repo:
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:
$ export GOPATH="$HOME/go"
$ mkdir -p "$GOPATH/src/github.com/restic"
$ cd "$GOPATH/src/github.com/restic"
$ git clone https://github.com/restic/restic $ git clone https://github.com/restic/restic
$ cd restic $ cd restic
$ gb build
[...] You can then build restic as follows:
$ bin/restic version
$ go build ./cmd/restic
$ ./restic version
restic compiled manually 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: The following commands can be used to run all the tests:
$ gb test $ go test ./cmd/... ./internal/...
ok github.com/restic/restic 8.174s
[...]
If you want to run your tests on Linux, OpenBSD or FreeBSD, you can use The repository contains two sets of directories with code: `cmd/` and
[vagrant](https://www.vagrantup.com/) with the provided `Vagrantfile` to `internal/` contain the code written for restic, whereas `vendor/` contains
quickly set up VMs and run the tests, e.g.: copies of libraries restic depends on. The libraries are managed with the
[`dep`](https://github.com/golang/dep) tool.
$ 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`.
Providing Patches 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 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 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, 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. that handle one and only one issue are easier to discuss and merge.
-57
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
Generated
+123
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
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"
+2 -2
View File
@@ -6,7 +6,7 @@ restic:
go run build.go go run build.go
clean: clean:
rm -rf restic rm -f restic
test: test:
go test ./... go test ./cmd/... ./internal/...
Vendored
-124
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
+18 -7
View File
@@ -27,10 +27,12 @@ var config = struct {
Main string Main string
Tests []string Tests []string
}{ }{
Name: "restic", // name of the program executable and directory Name: "restic", // name of the program executable and directory
Namespace: "", // subdir of GOPATH, e.g. "github.com/foo/bar" Namespace: "github.com/restic/restic", // subdir of GOPATH, e.g. "github.com/foo/bar"
Main: "cmds/restic", // package name for the main package Main: "github.com/restic/restic/cmd/restic", // package name for the main package
Tests: []string{"restic/...", "cmds/..."}, // tests to run 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 '_'). // specialDir returns true if the file begins with a special character ('.' or '_').
@@ -77,7 +79,12 @@ func excludePath(name string) bool {
// └── restic // └── restic
// └── foo.go // └── foo.go
func updateGopath(dst, src, prefix string) error { 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 { return filepath.Walk(src, func(name string, fi os.FileInfo, err error) error {
if name == src {
return err
}
if specialDir(name) { if specialDir(name) {
if fi.IsDir() { if fi.IsDir() {
return filepath.SkipDir return filepath.SkipDir
@@ -86,6 +93,10 @@ func updateGopath(dst, src, prefix string) error {
return nil return nil
} }
if err != nil {
return err
}
if fi.IsDir() { if fi.IsDir() {
return nil return nil
} }
@@ -368,13 +379,13 @@ func main() {
} }
verbosePrintf("create GOPATH at %v\n", gopath) 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) 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 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) die("copying files from %v to %v failed: %v\n", root, gopath, err)
} }
} }
@@ -4,7 +4,7 @@ import (
"syscall" "syscall"
"unsafe" "unsafe"
"restic/debug" "github.com/restic/restic/internal/debug"
) )
// IsProcessBackground returns true if it is running in the background or false if not // IsProcessBackground returns true if it is running in the background or false if not
@@ -7,7 +7,7 @@ import (
"sync" "sync"
"syscall" "syscall"
"restic/debug" "github.com/restic/restic/internal/debug"
) )
var cleanupHandlers struct { var cleanupHandlers struct {
@@ -7,17 +7,18 @@ import (
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"restic"
"strings" "strings"
"time" "time"
"github.com/restic/restic/internal"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic/archiver" "github.com/restic/restic/internal/archiver"
"restic/debug" "github.com/restic/restic/internal/debug"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/filter" "github.com/restic/restic/internal/filter"
"restic/fs" "github.com/restic/restic/internal/fs"
) )
var cmdBackup = &cobra.Command{ var cmdBackup = &cobra.Command{
@@ -8,10 +8,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic" "github.com/restic/restic/internal"
"restic/backend" "github.com/restic/restic/internal/backend"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/repository" "github.com/restic/restic/internal/repository"
) )
var cmdCat = &cobra.Command{ var cmdCat = &cobra.Command{
@@ -8,9 +8,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic" "github.com/restic/restic/internal"
"restic/checker" "github.com/restic/restic/internal/checker"
"restic/errors" "github.com/restic/restic/internal/errors"
) )
var cmdCheck = &cobra.Command{ var cmdCheck = &cobra.Command{
@@ -11,12 +11,12 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic" "github.com/restic/restic/internal"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/pack" "github.com/restic/restic/internal/pack"
"restic/repository" "github.com/restic/restic/internal/repository"
"restic/worker" "github.com/restic/restic/internal/worker"
) )
var cmdDump = &cobra.Command{ var cmdDump = &cobra.Command{
@@ -9,9 +9,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic" "github.com/restic/restic/internal"
"restic/debug" "github.com/restic/restic/internal/debug"
"restic/errors" "github.com/restic/restic/internal/errors"
) )
var cmdFind = &cobra.Command{ var cmdFind = &cobra.Command{
@@ -3,10 +3,11 @@ package main
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"restic"
"sort" "sort"
"strings" "strings"
"github.com/restic/restic/internal"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -2,8 +2,9 @@ package main
import ( import (
"context" "context"
"restic/errors"
"restic/repository" "github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -3,9 +3,10 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"restic"
"restic/errors" "github.com/restic/restic/internal"
"restic/repository" "github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -3,9 +3,10 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"restic"
"restic/errors" "github.com/restic/restic/internal"
"restic/index" "github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/index"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -6,9 +6,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic" "github.com/restic/restic/internal"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/repository" "github.com/restic/restic/internal/repository"
) )
var cmdLs = &cobra.Command{ var cmdLs = &cobra.Command{
@@ -1,8 +1,8 @@
package main package main
import ( import (
"restic" "github.com/restic/restic/internal"
"restic/migrations" "github.com/restic/restic/internal/migrations"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -6,15 +6,16 @@ package main
import ( import (
"context" "context"
"os" "os"
"restic"
"github.com/restic/restic/internal"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic/debug" "github.com/restic/restic/internal/debug"
"restic/errors" "github.com/restic/restic/internal/errors"
resticfs "restic/fs" resticfs "github.com/restic/restic/internal/fs"
"restic/fuse" "github.com/restic/restic/internal/fuse"
systemFuse "bazil.org/fuse" systemFuse "bazil.org/fuse"
"bazil.org/fuse/fs" "bazil.org/fuse/fs"
@@ -2,7 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"restic/options"
"github.com/restic/restic/internal/options"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -2,13 +2,14 @@ package main
import ( import (
"fmt" "fmt"
"restic"
"restic/debug"
"restic/errors"
"restic/index"
"restic/repository"
"time" "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" "github.com/spf13/cobra"
) )
@@ -2,8 +2,9 @@ package main
import ( import (
"context" "context"
"restic"
"restic/index" "github.com/restic/restic/internal"
"github.com/restic/restic/internal/index"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -1,10 +1,10 @@
package main package main
import ( import (
"restic" "github.com/restic/restic/internal"
"restic/debug" "github.com/restic/restic/internal/debug"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/filter" "github.com/restic/restic/internal/filter"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic" "github.com/restic/restic/internal"
) )
var cmdSnapshots = &cobra.Command{ var cmdSnapshots = &cobra.Command{
@@ -5,10 +5,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic" "github.com/restic/restic/internal"
"restic/debug" "github.com/restic/restic/internal/debug"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/repository" "github.com/restic/restic/internal/repository"
) )
var cmdTag = &cobra.Command{ var cmdTag = &cobra.Command{
@@ -2,7 +2,8 @@ package main
import ( import (
"context" "context"
"restic"
"github.com/restic/restic/internal"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -3,8 +3,8 @@ package main
import ( import (
"context" "context"
"restic" "github.com/restic/restic/internal"
"restic/repository" "github.com/restic/restic/internal/repository"
) )
// FindFilteredSnapshots yields Snapshots, either given explicitly by `snapshotIDs` or filtered from the list of all snapshots. // FindFilteredSnapshots yields Snapshots, either given explicitly by `snapshotIDs` or filtered from the list of all snapshots.
@@ -6,7 +6,7 @@ import (
"path/filepath" "path/filepath"
"time" "time"
"restic" "github.com/restic/restic/internal"
) )
func formatBytes(c uint64) string { func formatBytes(c uint64) string {
@@ -6,23 +6,24 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"restic"
"runtime" "runtime"
"strings" "strings"
"syscall" "syscall"
"restic/backend/b2" "github.com/restic/restic/internal"
"restic/backend/local"
"restic/backend/location"
"restic/backend/rest"
"restic/backend/s3"
"restic/backend/sftp"
"restic/backend/swift"
"restic/debug"
"restic/options"
"restic/repository"
"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" "golang.org/x/crypto/ssh/terminal"
) )
@@ -7,8 +7,9 @@ import (
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"restic/errors"
"restic/repository" "github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/repository"
"github.com/pkg/profile" "github.com/pkg/profile"
) )
@@ -12,9 +12,9 @@ import (
"testing" "testing"
"time" "time"
"restic" "github.com/restic/restic/internal"
"restic/repository" "github.com/restic/restic/internal/repository"
. "restic/test" . "github.com/restic/restic/internal/test"
) )
const ( const (
@@ -9,9 +9,9 @@ import (
"runtime" "runtime"
"testing" "testing"
"restic/options" "github.com/restic/restic/internal/options"
"restic/repository" "github.com/restic/restic/internal/repository"
. "restic/test" . "github.com/restic/restic/internal/test"
) )
type dirEntry struct { type dirEntry struct {
@@ -12,18 +12,19 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"restic"
"strings" "strings"
"syscall" "syscall"
"testing" "testing"
"time" "time"
"restic/errors" "github.com/restic/restic/internal"
"restic/debug" "github.com/restic/restic/internal/errors"
"restic/filter"
"restic/repository" "github.com/restic/restic/internal/debug"
. "restic/test" "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 { func parseIDsFromReader(t testing.TB, rd io.Reader) restic.IDs {
@@ -1099,7 +1100,7 @@ func TestFindJSON(t *testing.T) {
func TestRebuildIndex(t *testing.T) { func TestRebuildIndex(t *testing.T) {
withTestEnvironment(t, func(env *testEnvironment, gopts GlobalOptions) { 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) SetupTarTestFixture(t, env.base, datafile)
out, err := testRunCheckOutput(gopts) out, err := testRunCheckOutput(gopts)
@@ -2,8 +2,9 @@ package main
import ( import (
"path/filepath" "path/filepath"
. "restic/test"
"testing" "testing"
. "github.com/restic/restic/internal/test"
) )
func TestRestoreLocalLayout(t *testing.T) { func TestRestoreLocalLayout(t *testing.T) {
@@ -19,7 +20,7 @@ func TestRestoreLocalLayout(t *testing.T) {
} }
for _, test := range tests { 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) SetupTarTestFixture(t, env.base, datafile)
@@ -7,9 +7,9 @@ import (
"sync" "sync"
"time" "time"
"restic" "github.com/restic/restic/internal"
"restic/debug" "github.com/restic/restic/internal/debug"
"restic/repository" "github.com/restic/restic/internal/repository"
) )
var globalLocks struct { var globalLocks struct {
@@ -6,14 +6,15 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"restic"
"restic/debug"
"restic/options"
"runtime" "runtime"
"github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/options"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"restic/errors" "github.com/restic/restic/internal/errors"
) )
// cmdRoot is the base command when no other command has been specified. // cmdRoot is the base command when no other command has been specified.
@@ -3,11 +3,12 @@ package archiver
import ( import (
"context" "context"
"io" "io"
"restic"
"restic/debug"
"time" "time"
"restic/errors" "github.com/restic/restic/internal"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/chunker" "github.com/restic/chunker"
) )
@@ -6,10 +6,11 @@ import (
"errors" "errors"
"io" "io"
"math/rand" "math/rand"
"restic"
"restic/checker"
"restic/repository"
"testing" "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 { func loadBlob(t *testing.T, repo restic.Repository, id restic.ID, buf []byte) int {
@@ -7,17 +7,18 @@ import (
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"restic"
"sort" "sort"
"sync" "sync"
"time" "time"
"restic/errors" "github.com/restic/restic/internal"
"restic/walk"
"restic/debug" "github.com/restic/restic/internal/errors"
"restic/fs" "github.com/restic/restic/internal/walk"
"restic/pipe"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/pipe"
"github.com/restic/chunker" "github.com/restic/chunker"
) )
@@ -9,12 +9,12 @@ import (
"testing" "testing"
"time" "time"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic" "github.com/restic/restic/internal"
"restic/archiver" "github.com/restic/restic/internal/archiver"
"restic/mock" "github.com/restic/restic/internal/mock"
"restic/repository" "github.com/restic/restic/internal/repository"
) )
const parallelSaves = 50 const parallelSaves = 50
@@ -5,8 +5,8 @@ import (
"os" "os"
"testing" "testing"
"restic/pipe" "github.com/restic/restic/internal/pipe"
"restic/walk" "github.com/restic/restic/internal/walk"
) )
var treeJobs = []string{ var treeJobs = []string{
@@ -7,14 +7,14 @@ import (
"testing" "testing"
"time" "time"
"restic" "github.com/restic/restic/internal"
"restic/archiver" "github.com/restic/restic/internal/archiver"
"restic/checker" "github.com/restic/restic/internal/checker"
"restic/crypto" "github.com/restic/restic/internal/crypto"
"restic/repository" "github.com/restic/restic/internal/repository"
. "restic/test" . "github.com/restic/restic/internal/test"
"restic/errors" "github.com/restic/restic/internal/errors"
"github.com/restic/chunker" "github.com/restic/chunker"
) )
@@ -2,8 +2,9 @@ package archiver
import ( import (
"context" "context"
"restic"
"testing" "testing"
"github.com/restic/restic/internal"
) )
// TestSnapshot creates a new snapshot of path. // TestSnapshot creates a new snapshot of path.
@@ -4,12 +4,13 @@ import (
"context" "context"
"io" "io"
"path" "path"
"restic"
"strings" "strings"
"restic/backend" "github.com/restic/restic/internal"
"restic/debug"
"restic/errors" "github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/kurin/blazer/b2" "github.com/kurin/blazer/b2"
) )
@@ -7,11 +7,11 @@ import (
"testing" "testing"
"time" "time"
"restic" "github.com/restic/restic/internal"
"restic/backend/b2" "github.com/restic/restic/internal/backend/b2"
"restic/backend/test" "github.com/restic/restic/internal/backend/test"
. "restic/test" . "github.com/restic/restic/internal/test"
) )
func newB2TestSuite(t testing.TB) *test.Suite { func newB2TestSuite(t testing.TB) *test.Suite {
@@ -5,8 +5,8 @@ import (
"regexp" "regexp"
"strings" "strings"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/options" "github.com/restic/restic/internal/options"
) )
// Config contains all configuration necessary to connect to an b2 compatible // Config contains all configuration necessary to connect to an b2 compatible
@@ -3,8 +3,9 @@ package backend
import ( import (
"net" "net"
"net/http" "net/http"
"restic/debug"
"time" "time"
"github.com/restic/restic/internal/debug"
) )
// Transport returns a new http.RoundTripper with default settings applied. // Transport returns a new http.RoundTripper with default settings applied.
@@ -5,10 +5,11 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"restic"
"restic/debug" "github.com/restic/restic/internal"
"restic/errors" "github.com/restic/restic/internal/debug"
"restic/fs" "github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/fs"
) )
// Layout computes paths for file name storage. // Layout computes paths for file name storage.
@@ -2,7 +2,8 @@ package backend
import ( import (
"encoding/hex" "encoding/hex"
"restic"
"github.com/restic/restic/internal"
) )
// DefaultLayout implements the default layout for local and sftp backends, as // DefaultLayout implements the default layout for local and sftp backends, as
@@ -1,6 +1,6 @@
package backend package backend
import "restic" import "github.com/restic/restic/internal"
// RESTLayout implements the default layout for the REST protocol. // RESTLayout implements the default layout for the REST protocol.
type RESTLayout struct { type RESTLayout struct {
@@ -1,6 +1,6 @@
package backend package backend
import "restic" import "github.com/restic/restic/internal"
// S3LegacyLayout implements the old layout used for s3 cloud storage backends, as // S3LegacyLayout implements the old layout used for s3 cloud storage backends, as
// described in the Design document. // described in the Design document.
@@ -5,10 +5,11 @@ import (
"path" "path"
"path/filepath" "path/filepath"
"reflect" "reflect"
"restic"
. "restic/test"
"sort" "sort"
"testing" "testing"
"github.com/restic/restic/internal"
. "github.com/restic/restic/internal/test"
) )
func TestDefaultLayout(t *testing.T) { func TestDefaultLayout(t *testing.T) {
@@ -3,8 +3,8 @@ package local
import ( import (
"strings" "strings"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/options" "github.com/restic/restic/internal/options"
) )
// Config holds all information needed to open a local repository. // Config holds all information needed to open a local repository.
@@ -3,9 +3,10 @@ package local
import ( import (
"context" "context"
"path/filepath" "path/filepath"
"restic"
. "restic/test"
"testing" "testing"
"github.com/restic/restic/internal"
. "github.com/restic/restic/internal/test"
) )
func TestLayout(t *testing.T) { func TestLayout(t *testing.T) {
@@ -5,13 +5,14 @@ import (
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"restic"
"restic/errors" "github.com/restic/restic/internal"
"restic/backend" "github.com/restic/restic/internal/errors"
"restic/debug"
"restic/fs" "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. // Local is a backend in a local directory.
@@ -2,12 +2,13 @@ package local_test
import ( import (
"io/ioutil" "io/ioutil"
"restic"
"testing" "testing"
"restic/backend/local" "github.com/restic/restic/internal"
"restic/backend/test"
. "restic/test" "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 { func newTestSuite(t testing.TB) *test.Suite {
@@ -4,7 +4,8 @@ package local
import ( import (
"os" "os"
"restic/fs"
"github.com/restic/restic/internal/fs"
) )
// set file to readonly // set file to readonly
@@ -4,13 +4,13 @@ package location
import ( import (
"strings" "strings"
"restic/backend/b2" "github.com/restic/restic/internal/backend/b2"
"restic/backend/local" "github.com/restic/restic/internal/backend/local"
"restic/backend/rest" "github.com/restic/restic/internal/backend/rest"
"restic/backend/s3" "github.com/restic/restic/internal/backend/s3"
"restic/backend/sftp" "github.com/restic/restic/internal/backend/sftp"
"restic/backend/swift" "github.com/restic/restic/internal/backend/swift"
"restic/errors" "github.com/restic/restic/internal/errors"
) )
// Location specifies the location of a repository, including the method of // Location specifies the location of a repository, including the method of
@@ -5,12 +5,12 @@ import (
"reflect" "reflect"
"testing" "testing"
"restic/backend/b2" "github.com/restic/restic/internal/backend/b2"
"restic/backend/local" "github.com/restic/restic/internal/backend/local"
"restic/backend/rest" "github.com/restic/restic/internal/backend/rest"
"restic/backend/s3" "github.com/restic/restic/internal/backend/s3"
"restic/backend/sftp" "github.com/restic/restic/internal/backend/sftp"
"restic/backend/swift" "github.com/restic/restic/internal/backend/swift"
) )
func parseURL(s string) *url.URL { func parseURL(s string) *url.URL {
@@ -5,12 +5,13 @@ import (
"context" "context"
"io" "io"
"io/ioutil" "io/ioutil"
"restic"
"sync" "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 type memMap map[restic.Handle][]byte
@@ -2,13 +2,14 @@ package mem_test
import ( import (
"context" "context"
"restic"
"testing" "testing"
"restic/errors" "github.com/restic/restic/internal"
"restic/backend/mem" "github.com/restic/restic/internal/errors"
"restic/backend/test"
"github.com/restic/restic/internal/backend/mem"
"github.com/restic/restic/internal/backend/test"
) )
type memConfig struct { type memConfig struct {
@@ -4,8 +4,8 @@ import (
"net/url" "net/url"
"strings" "strings"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/options" "github.com/restic/restic/internal/options"
) )
// Config contains all configuration necessary to connect to a REST server. // Config contains all configuration necessary to connect to a REST server.
@@ -9,15 +9,16 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
"restic"
"strings" "strings"
"github.com/restic/restic/internal"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
"restic/debug" "github.com/restic/restic/internal/debug"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/backend" "github.com/restic/restic/internal/backend"
) )
// make sure the rest backend implements restic.Backend // make sure the rest backend implements restic.Backend
@@ -7,13 +7,14 @@ import (
"net/url" "net/url"
"os" "os"
"os/exec" "os/exec"
"restic"
"testing" "testing"
"time" "time"
"restic/backend/rest" "github.com/restic/restic/internal"
"restic/backend/test"
. "restic/test" "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() { func runRESTServer(ctx context.Context, t testing.TB, dir string) func() {
@@ -5,8 +5,8 @@ import (
"path" "path"
"strings" "strings"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/options" "github.com/restic/restic/internal/options"
) )
// Config contains all configuration necessary to connect to an s3 compatible // Config contains all configuration necessary to connect to an s3 compatible
@@ -7,17 +7,18 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
"restic"
"strings" "strings"
"time" "time"
"restic/backend" "github.com/restic/restic/internal"
"restic/errors"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/errors"
"github.com/minio/minio-go" "github.com/minio/minio-go"
"github.com/minio/minio-go/pkg/credentials" "github.com/minio/minio-go/pkg/credentials"
"restic/debug" "github.com/restic/restic/internal/debug"
) )
// Backend stores data on an S3 endpoint. // Backend stores data on an S3 endpoint.
@@ -11,13 +11,14 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"restic"
"testing" "testing"
"time" "time"
"restic/backend/s3" "github.com/restic/restic/internal"
"restic/backend/test"
. "restic/test" "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) { func mkdir(t testing.TB, dir string) {
@@ -1,6 +1,6 @@
package backend package backend
import "restic/errors" import "github.com/restic/restic/internal/errors"
// Semaphore limits access to a restricted resource. // Semaphore limits access to a restricted resource.
type Semaphore struct { type Semaphore struct {
@@ -5,8 +5,8 @@ import (
"path" "path"
"strings" "strings"
"restic/errors" "github.com/restic/restic/internal/errors"
"restic/options" "github.com/restic/restic/internal/options"
) )
// Config collects all information required to connect to an sftp server. // 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