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

Commit b461c3f

Browse files
committed
Merge branch 'master' into new-ensure
2 parents f38e02b + f6f8423 commit b461c3f

Some content is hidden

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

78 files changed

+3116
-1088
lines changed

.github/CODEOWNERS

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# general
2+
* @sdboyer
3+
4+
# init
5+
/cmd/dep/init* @carolynvs
6+
/cmd/dep/gopath_scanner* @carolynvs
7+
/cmd/dep/root_analyzer* @carolynvs
8+
/cmd/dep/*_importer* @carolynvs
9+
/cmd/dep/testdata/glide @carolynvs
10+
/cmd/dep/testdata/godep @carolynvs
11+
/cmd/dep/testdata/harness_tests/init @carolynvs
12+
/cmd/dep/testdata/init** @carolynvs
13+
/analyzer* @carolynvs
14+
/testdata/analyzer @carolynvs
15+
/internal/feedback @carolynvs
16+
17+
# ensure
18+
/cmd/dep/ensure* @ibrasho
19+
/cmd/dep/testdata/harness_tests/ensure** @ibrasho
20+
21+
# status
22+
/cmd/dep/status* @darkowlzz
23+
/cmd/dep/testdata/harness_tests/status** @darkowlzz
24+
/cmd/dep/graphviz* @darkowlzz
25+
26+
# gps caching
27+
/internal/gps/source_cache* @jmank88

.github/ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
33
Thanks for filing an issue! If this is a question or feature request, just delete
4-
everthing here and write out the request, providing as much context as you can.
4+
everything here and write out the request, providing as much context as you can.
55
66
-->
77

.github/PULL_REQUEST_TEMPLATE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<--
1+
<!--
22
Work-in-progress PRs are welcome as a way to get early feedback - just prefix
33
the title with [WIP].
44
-->
@@ -11,7 +11,7 @@ the title with [WIP].
1111

1212
### Which issue(s) does this PR fix?
1313

14-
<--
14+
<!--
1515
1616
fixes #
1717
fixes #

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Keep an eye on the [Roadmap](https://github.com/golang/dep/wiki/Roadmap) for a s
88

99
## Filing issues
1010

11-
Please check the existing issues and [FAQ](FAQ.md) to see if your feedback has already been reported.
11+
Please check the existing issues and [FAQ](docs/FAQ.md) to see if your feedback has already been reported.
1212

1313
When [filing an issue](https://github.com/golang/dep/issues/new), make sure to answer these five questions:
1414

Gopkg.lock

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MAINTAINERS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ General maintainers:
1212
* source manager: (vacant)
1313
* root deduction: (vacant)
1414
* source/vcs interaction: (vacant)
15-
* caching: (vacant)
15+
* caching: Jordan Krage (@jmank88)
1616
* pkgtree: (vacant)
1717
* versions and constraints: (vacant)

README.md

+170-17
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ Dep is a prototype dependency management tool. It requires Go 1.7 or newer to co
88

99
## Current status
1010

11-
**Alpha**.
12-
Functionality is known to be broken, missing or incomplete. Changes are planned
13-
to the CLI commands soon. *It would be unwise to write scripts atop `dep` before then.*
14-
The repository is open to solicit feedback and contributions from the community.
15-
Please see below for feedback and contribution guidelines.
11+
`dep` is safe for production use. That means two things:
1612

17-
`Gopkg.toml` and `Gopkg.lock` have reached a stable structure, and it is safe to
18-
commit them in your projects. We plan to add more to these files, but we
19-
guarantee these changes will be backwards-compatible.
13+
* Any valid metadata file (`Gopkg.toml` and `Gopkg.lock`) will be readable and considered valid by any future version of `dep`.
14+
* Generally speaking, it has comparable or fewer bugs than other tools out there.
15+
16+
That said, keep in mind the following:
17+
18+
* `dep` is still changing rapidly. If you need stability (e.g. for CI), it's best to rely on a released version, not tip.
19+
* [Some changes](https://github.com/golang/dep/pull/489) are pending to the CLI interface. Scripting on dep before they land is unwise.
20+
* `dep`'s exported API interface will continue to change in unpredictable, backwards-incompatible ways until we tag a v1.0.0 release.
2021

2122
## Context
2223

@@ -26,38 +27,191 @@ guarantee these changes will be backwards-compatible.
2627
- [User Stories](https://docs.google.com/document/d/1wT8e8wBHMrSRHY4UF_60GCgyWGqvYye4THvaDARPySs/edit)
2728
- [Features](https://docs.google.com/document/d/1JNP6DgSK-c6KqveIhQk-n_HAw3hsZkL-okoleM43NgA/edit)
2829
- [Design Space](https://docs.google.com/document/d/1TpQlQYovCoX9FkpgsoxzdvZplghudHAiQOame30A-v8/edit)
29-
- [Frequently Asked Questions](FAQ.md)
30+
- [Frequently Asked Questions](docs/FAQ.md)
3031

31-
## Usage
32+
## Setup
3233

3334
Get the tool via
3435

3536
```sh
3637
$ go get -u github.com/golang/dep/cmd/dep
3738
```
3839

39-
Typical usage on a new repo might be
40+
To start managing dependencies using dep, run the following from your project root directory:
4041

4142
```sh
4243
$ dep init
43-
$ dep ensure -update
4444
```
4545

46-
To update a dependency to a new version, you might run
46+
This does the following:
47+
48+
1. Look for [existing dependency management files](docs/FAQ.md#what-external-tools-are-supported) to convert
49+
1. Check if your dependencies use dep
50+
1. Identify your dependencies
51+
1. Back up your existing `vendor/` directory (if you have one) to
52+
`_vendor-TIMESTAMP/`
53+
1. Pick the highest compatible version for each dependency
54+
1. Generate [`Gopkg.toml`](docs/Gopkg.toml.md) ("manifest") and `Gopkg.lock` files
55+
1. Install the dependencies in `vendor/`
56+
57+
## Usage
58+
59+
There is one main subcommand you will use: `dep ensure`. `ensure` first makes
60+
sure `Gopkg.lock` is consistent with your `import`s and `Gopkg.toml`. If any
61+
changes are detected, it then populates `vendor/` with exactly what's described
62+
in `Gopkg.lock`.
63+
64+
`dep ensure` is safe to run early and often. See the help text for more detailed
65+
usage instructions.
66+
67+
```sh
68+
$ dep help ensure
69+
```
70+
71+
### Installing dependencies
72+
73+
(if your `vendor/` directory isn't [checked in with your code](docs/FAQ.md#should-i-commit-my-vendor-directory))
74+
75+
<!-- may change with https://github.com/golang/dep/pull/489 -->
76+
77+
```sh
78+
$ dep ensure
79+
```
80+
81+
If a dependency already exists in your `vendor/` folder, dep will ensure it
82+
matches the constraints from the manifest. If the dependency is missing from
83+
`vendor/`, the latest version allowed by your manifest will be installed.
84+
85+
### Adding a dependency
86+
87+
1. `import` the package in your `*.go` source code file(s).
88+
1. Run the following command to update your `Gopkg.lock` and populate `vendor/` with the new dependency.
89+
90+
```sh
91+
$ dep ensure
92+
```
93+
94+
### Changing dependencies
95+
96+
If you want to:
97+
98+
* Change the allowed `version`/`branch`/`revision`
99+
* Switch to using a fork
100+
101+
for one or more dependencies, do the following:
102+
103+
1. Modify your `Gopkg.toml`.
104+
1. Run
105+
106+
```sh
107+
$ dep ensure
108+
```
109+
110+
### Checking the status of dependencies
111+
112+
Run `dep status` to see the current status of all your dependencies.
47113

48114
```sh
49-
$ dep ensure github.com/pkg/errors@^0.8.0
115+
$ dep status
116+
PROJECT CONSTRAINT VERSION REVISION LATEST
117+
github.com/Masterminds/semver branch 2.x branch 2.x 139cc09 c2e7f6c
118+
github.com/Masterminds/vcs ^1.11.0 v1.11.1 3084677 3084677
119+
github.com/armon/go-radix * branch master 4239b77 4239b77
50120
```
51121

52-
See the help text for more detailed usage instructions.
122+
On top of that, if you have added new imports to your project or modified the manifest file without running `dep ensure` again, `dep status` will tell you there is a mismatch between the lock file and the current status of the project.
123+
124+
```sh
125+
$ dep status
126+
Lock inputs-digest mismatch due to the following packages missing from the lock:
127+
128+
PROJECT MISSING PACKAGES
129+
github.com/Masterminds/goutils [github.com/Masterminds/goutils]
130+
131+
This happens when a new import is added. Run `dep ensure` to install the missing packages.
132+
```
133+
134+
As `dep status` suggests, run `dep ensure` to update your lockfile. Then run `dep status` again, and the lock mismatch should go away.
135+
136+
### Updating dependencies
137+
138+
(to the latest version allowed by the manifest)
139+
140+
```sh
141+
$ dep ensure -update
142+
```
143+
144+
### Removing dependencies
145+
146+
1. Remove the `import`s and all usage from your code.
147+
1. Run
148+
149+
```sh
150+
$ dep ensure
151+
```
152+
153+
1. Remove from `Gopkg.toml`, if it was in there.
154+
155+
### Testing changes to a dependency
156+
157+
Making changes in your `vendor/` directory directly is not recommended, as dep
158+
will overwrite any changes. Instead:
159+
160+
1. Delete the dependency from the `vendor/` directory.
161+
162+
```sh
163+
rm -rf vendor/<dependency>
164+
```
165+
166+
1. Add that dependency to your `GOPATH`, if it isn't already.
167+
168+
```sh
169+
$ go get <dependency>
170+
```
171+
172+
1. Modify the dependency in `$GOPATH/src/<dependency>`.
173+
1. Test, build, etc.
174+
175+
Don't run `dep ensure` until you're done. `dep ensure` will reinstall the
176+
dependency into `vendor/` based on your manifest, as if you were installing from
177+
scratch.
178+
179+
This solution works for short-term use, but for something long-term, take a look
180+
at [virtualgo](https://github.com/GetStream/vg).
181+
182+
To test out code that has been pushed as a new version, or to a branch or fork,
183+
see [changing dependencies](#changing-dependencies).
184+
185+
## Semantic Versioning
186+
187+
`dep ensure` a uses an external [semver library](https://github.com/Masterminds/semver) to interpret the version constraints you specify in the manifest. The comparison operators are:
188+
189+
* `=`: equal
190+
* `!=`: not equal
191+
* `>`: greater than
192+
* `<`: less than
193+
* `>=`: greater than or equal to
194+
* `<=`: less than or equal to
195+
* `-`: literal range. Eg: 1.2 - 1.4.5 is equivalent to >= 1.2, <= 1.4.5
196+
* `~`: minor range. Eg: ~1.2.3 is equivalent to >= 1.2.3, < 1.3.0
197+
* `^`: major range. Eg: ^1.2.3 is equivalent to >= 1.2.3, < 2.0.0
198+
* `[xX*]`: wildcard. Eg: 1.2.x is equivalent to >= 1.2.0, < 1.3.0
199+
200+
You might, for example, include a constraint in your manifest that specifies `version = "=2.0.0"` to pin a dependency to version 2.0.0, or constrain to minor releases with: `version = "2.*"`. Refer to the [semver library](https://github.com/Masterminds/semver) documentation for more info.
201+
202+
**Note**: When you specify a version *without an operator*, `dep` automatically uses the `^` operator by default. `dep ensure` will interpret the given version as the min-boundry of a range, for example:
203+
204+
* `1.2.3` becomes the range `>=1.2.3, <2.0.0`
205+
* `0.2.3` becomes the range `>=0.2.3, <0.3.0`
206+
* `0.0.3` becomes the range `>=0.0.3, <0.1.0`
53207
54208
## Feedback
55209
56210
Feedback is greatly appreciated.
57211
At this stage, the maintainers are most interested in feedback centered on the user experience (UX) of the tool.
58212
Do you have workflows that the tool supports well, or doesn't support at all?
59213
Do any of the commands have surprising effects, output, or results?
60-
Please check the existing issues and [FAQ](FAQ.md) to see if your feedback has already been reported.
214+
Please check the existing issues and [FAQ](docs/FAQ.md) to see if your feedback has already been reported.
61215
If not, please file an issue, describing what you did or wanted to do, what you expected to happen, and what actually happened.
62216

63217
## Contributing
@@ -67,4 +221,3 @@ The maintainers actively manage the issues list, and try to highlight issues sui
67221
The project follows the typical GitHub pull request model.
68222
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
69223
Before starting any work, please either comment on an existing issue, or file a new one.
70-

analyzer.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ func (a Analyzer) DeriveManifestAndLock(path string, n gps.ProjectRoot) (gps.Man
4040
if err != nil {
4141
return nil, nil, err
4242
}
43-
// TODO: No need to return lock til we decide about preferred versions, see
44-
// https://github.com/sdboyer/gps/wiki/gps-for-Implementors#preferred-versions.
43+
4544
return m, nil, nil
4645
}
4746

appveyor.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ clone_folder: c:\gopath\src\github.com\golang\dep
88
environment:
99
GOPATH: c:\gopath
1010
DEPTESTBYPASS501: 1
11-
matrix:
12-
- environment:
13-
GOVERSION: 1.7.5
14-
- environment:
15-
GOVERSION: 1.8
11+
GOVERSION: 1.8
1612

1713
init:
1814
- git config --global core.autocrlf input

0 commit comments

Comments
 (0)