Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into source_cache_close
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Aug 29, 2017
2 parents b9134b0 + f373037 commit 4fd3c3b
Show file tree
Hide file tree
Showing 30 changed files with 220 additions and 242 deletions.
7 changes: 5 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ everything here and write out the request, providing as much context as you can.
-->

### What version of Go (`go version`) and `dep` (`git describe --tags`) are you using?
### What version of `dep` are you using (`dep version`)?
<!--
If you installed `dep` via `go get`, report the version instead with
`cd $GOPATH/src/github.com/golang/dep && git describe --tags`
-->

### What `dep` command did you run?

Expand All @@ -20,4 +24,3 @@ The output of `dep hash-inputs` may also be helpful to include.
### What did you expect to see?

### What did you see instead?

37 changes: 28 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
language: go
sudo: false
notifications:
email: false
jobs:
include:
- stage: test
go_import_path: github.com/golang/dep
install:
- go get -u honnef.co/go/tools/cmd/{gosimple,staticcheck}
- npm install -g codeclimate-test-reporter
Expand All @@ -15,20 +15,16 @@ jobs:
go: 1.8.x
script:
- go build -v ./cmd/dep
- PKGS=$(go list ./... | grep -v /vendor/)
- go vet $PKGS
- staticcheck $PKGS
- gosimple $PKGS
- ./hack/lint.bash
- ./hack/validate-vendor.bash
- go build ./hack/licenseok
- find . -path ./vendor -prune -o -type f -name "*.go" -printf '%P\n' | xargs ./licenseok
- set -e; for pkg in $PKGS; do go test -race -coverprofile=profile.out -covermode=atomic $pkg; if [[ -f profile.out ]]; then cat profile.out >> coverage.txt; rm profile.out; fi; done
- ./hack/coverage.bash
after_success:
- codeclimate-test-reporter < coverage.txt
# YAML alias, for settings shared across the simpler builds
- &simple-test
go: 1.7.x
go: 1.9.x
stage: test
go_import_path: github.com/golang/dep
install: skip
env:
- DEPTESTBYPASS501=1
Expand All @@ -53,3 +49,26 @@ jobs:
# Related: https://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
- trap EXIT
- go test -race $(go list ./... | grep -v vendor)
- go: 1.8.x
stage: deploy
go_import_path: github.com/golang/dep
install: skip
script: skip
before_deploy:
- ./hack/build-all.bash
deploy:
- provider: releases
api_key:
secure: fL9GX11J3JLizEBTPZHN32wuAT91eAJsGl0kjlAdIc6Lb/9UCe1XZGgFnpQFN4qo/S+omhHBDbM6Ty1xhNy7xmjDecpQGDU8Rmap9Oll0TuxqMigG+njOuPp5VUYPofPP0PGKdxAcYg+KaFM7x0o2rK+qA046NHwo2gH1BbE+bn55TZglEajEfc8j9iX4jt96KC7zlu+WiKArLmfUtlrI8m8ZYgbYcvFmlYjeCiEqlNhvNL59ejug9Rl0PLtPbamqVXkGLafYtekgPCb4WSxBiCt8pq5Rb5svk9YcdXpiaWQhZjMPAuKN6BrmN2lw1PiXzADUG5fjvNc8eo2HY70GD2utU9cAsY8VIafhoH5n6uM1WI8MHwDfd7P1PiQA3ZGQ8CPwk4q/8HSfQU9ap7vZgSF63pTIbtlviyIG67orOJE9PWWncl9olYM946UylZu6m3hWI/rmJxOeJ1UJjym/3GNPMRfKubaGhV/TyRdM0bKX4M0cXHU6k/ESVFupGXdKRt4RpvkD4/1Km6b2OShW6PNI+ifFspnJr7obkI7dm7ubySdnNz4lMv9WWymxRpMVc8hUAhuoDvXeZJq7pSnkjBEWDxIRoTkA93CU3/Rf7MFYCJMnGSqjcxWUpIfCAk2/r4BqL9NQnqBvvVt+MYi64QaD5n7ZF3dVbr6HZ2zjSU=
file:
- release/dep-linux-amd64
- release/dep-linux-amd64.sha256
- release/dep-darwin-amd64
- release/dep-darwin-amd64.sha256
- release/dep-windows-amd64
- release/dep-windows-amd64.sha256
skip_cleanup: true
on:
repo: golang/dep
branch: master
tags: true
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Dep

`dep` is a prototype dependency management tool for Go. It requires Go 1.7 or newer to compile.
`dep` is a prototype dependency management tool for Go. It requires Go 1.8 or newer to compile.

`dep` is the official _experiment_, but not yet the official tool. Check out the [Roadmap](https://github.com/golang/dep/wiki/Roadmap) for more on what this means!

Expand Down Expand Up @@ -39,11 +39,7 @@ That said, keep in mind the following:

## Setup

Get the tool via

```sh
$ go get -u github.com/golang/dep/cmd/dep
```
Grab the latest binary from the [releases](https://github.com/golang/dep/releases) page.

On macOS you can install or upgrade to the latest released version with Homebrew:

Expand All @@ -52,6 +48,12 @@ $ brew install dep
$ brew upgrade dep
```

If you're interested in hacking on `dep`, you can install via `go get`:

```sh
go get -u github.com/golang/dep/cmd/dep
```

To start managing dependencies using dep, run the following from your project's root directory:

```sh
Expand Down
1 change: 1 addition & 0 deletions cmd/dep/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (c *Config) Run() (exitCode int) {
&ensureCommand{},
&hashinCommand{},
&pruneCommand{},
&versionCommand{},
}

examples := [][2]string{
Expand Down
4 changes: 3 additions & 1 deletion cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
// deterministically ordered. (This may be superfluous if the lock is always
// written in alpha order, but it doesn't hurt to double down.)
slp := p.Lock.Projects()
sort.Sort(dep.SortedLockedProjects(slp))
sort.Slice(slp, func(i, j int) bool {
return slp[i].Ident().Less(slp[j].Ident())
})

if bytes.Equal(s.HashInputs(), p.Lock.SolveMeta.InputsDigest) {
// If these are equal, we're guaranteed that the lock is a transitively
Expand Down
45 changes: 45 additions & 0 deletions cmd/dep/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
"flag"
"runtime"

"github.com/golang/dep"
)

var (
version = "devel"
buildDate string
commitHash string
)

const versionHelp = `Show the dep version information`

func (cmd *versionCommand) Name() string { return "version" }
func (cmd *versionCommand) Args() string {
return ""
}
func (cmd *versionCommand) ShortHelp() string { return versionHelp }
func (cmd *versionCommand) LongHelp() string { return versionHelp }
func (cmd *versionCommand) Hidden() bool { return false }

func (cmd *versionCommand) Register(fs *flag.FlagSet) {}

type versionCommand struct{}

func (cmd *versionCommand) Run(ctx *dep.Ctx, args []string) error {
ctx.Out.Printf(`dep:
version : %s
build date : %s
git hash : %s
go version : %s
go compiler : %s
platform : %s/%s
`, version, buildDate, commitHash,
runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH)
return nil
}
37 changes: 37 additions & 0 deletions hack/build-all.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Copyright 2017 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# This script will build dep and calculate hash for each
# (DEP_BUILD_PLATFORMS, DEP_BUILD_ARCHS) pair.
# DEP_BUILD_PLATFORMS="linux" DEP_BUILD_ARCHS="amd64" ./hack/build-all.sh
# can be called to build only for linux-amd64

set -e

VERSION=$(git describe --tags --dirty)
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
DATE=$(date --iso-8601)

GO_BUILD_CMD="go build -a -installsuffix cgo"
GO_BUILD_LDFLAGS="-s -w -X main.commitHash=$COMMIT_HASH -X main.buildDate=$DATE -X main.version=$VERSION"

if [ -z "$DEP_BUILD_PLATFORMS" ]; then
DEP_BUILD_PLATFORMS="linux windows darwin"
fi

if [ -z "$DEP_BUILD_ARCHS" ]; then
DEP_BUILD_ARCHS="amd64"
fi

mkdir -p release

for OS in ${DEP_BUILD_PLATFORMS[@]}; do
for ARCH in ${DEP_BUILD_ARCHS[@]}; do
echo "Building for $OS/$ARCH"
GOARCH=$ARCH GOOS=$OS CGO_ENABLED=0 $GO_BUILD_CMD -ldflags "$GO_BUILD_LDFLAGS"\
-o "release/dep-$OS-$ARCH" ./cmd/dep/
sha256sum "release/dep-$OS-$ARCH" > "release/dep-$OS-$ARCH".sha256
done
done
16 changes: 16 additions & 0 deletions hack/coverage.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Copyright 2017 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# This script will generate coverage.txt
set -e

PKGS=$(go list ./... | grep -v /vendor/)
for pkg in $PKGS; do
go test -race -coverprofile=profile.out -covermode=atomic $pkg
if [[ -f profile.out ]]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
12 changes: 12 additions & 0 deletions hack/lint.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Copyright 2017 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# This script will validate code with various linters
set -e

PKGS=$(go list ./... | grep -v /vendor/)
go vet $PKGS
staticcheck $PKGS
gosimple $PKGS
12 changes: 12 additions & 0 deletions hack/validate-licence.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Copyright 2017 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# This script will build licenseok and run it on all
# source files to check licence
set -e

go build ./hack/licenseok
find . -path ./vendor -prune -o -type f -name "*.go"\
-printf '%P\n' | xargs ./licenseok
2 changes: 1 addition & 1 deletion internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func RenameWithFallback(src, dst string) error {
return errors.Wrapf(err, "cannot stat %s", src)
}

err = rename(src, dst)
err = os.Rename(src, dst)
if err == nil {
return nil
}
Expand Down
5 changes: 0 additions & 5 deletions internal/fs/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

// +build !windows
// +build go1.8

package fs

Expand All @@ -14,10 +13,6 @@ import (
"github.com/pkg/errors"
)

func rename(src, dst string) error {
return os.Rename(src, dst)
}

// renameFallback attempts to determine the appropriate fallback to failed rename
// operation depending on the resulting error.
func renameFallback(err error, src, dst string) error {
Expand Down
50 changes: 0 additions & 50 deletions internal/fs/rename_go17.go

This file was deleted.

4 changes: 0 additions & 4 deletions internal/fs/rename_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import (
"github.com/pkg/errors"
)

func rename(src, dst string) error {
return os.Rename(src, dst)
}

// renameFallback attempts to determine the appropriate fallback to failed rename
// operation depending on the resulting error.
func renameFallback(err error, src, dst string) error {
Expand Down
20 changes: 6 additions & 14 deletions internal/gps/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ func (m ProjectConstraints) asSortedSlice() []ProjectConstraint {
k++
}

sort.Stable(sortedConstraints(pcs))
sort.SliceStable(pcs, func(i, j int) bool {
return pcs[i].Ident.Less(pcs[j].Ident)
})
return pcs
}

Expand All @@ -348,7 +350,9 @@ func (m ProjectConstraints) overrideAll(pcm ProjectConstraints) (out []workingCo
k++
}

sort.Stable(sortedWC(out))
sort.SliceStable(out, func(i, j int) bool {
return out[i].Ident.Less(out[j].Ident)
})
return
}

Expand Down Expand Up @@ -389,15 +393,3 @@ func (m ProjectConstraints) override(pr ProjectRoot, pp ProjectProperties) worki

return wc
}

type sortedConstraints []ProjectConstraint

func (s sortedConstraints) Len() int { return len(s) }
func (s sortedConstraints) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sortedConstraints) Less(i, j int) bool { return s[i].Ident.less(s[j].Ident) }

type sortedWC []workingConstraint

func (s sortedWC) Len() int { return len(s) }
func (s sortedWC) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sortedWC) Less(i, j int) bool { return s[i].Ident.less(s[j].Ident) }
Loading

0 comments on commit 4fd3c3b

Please sign in to comment.