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

Expand example Gopkg.toml text; always add on init #462

Merged
merged 5 commits into from
Apr 28, 2017

Conversation

sdboyer
Copy link
Member

@sdboyer sdboyer commented Apr 26, 2017

This expands the example text we add to Gopkg.toml to cover all valid values for the file.

It also changes the behavior of dep init to write out the example data unconditionally to the bottom of Gopkg.toml, rather than doing so only if nothing was to populate the manifest.

I'm not sure this latter part is the best idea, but being that there will be precious few situations under which we'd have an empty manifest (once init changes are done, #277), it seems worth being more aggressive about writing out these examples.

We could also add a flag to init that allows the user to suppress writing out the examples.

Copy link
Contributor

@zellyn zellyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

# revision = "abc123"

## Overrides have the same structure as [[dependencies]], but supercede all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supersede

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, no kidding 😛

##
## Overrides are a sledgehammer, and should be used only as a last resort.
# [[overrides]]
## Required: the root import path of the project being constrained
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just note that they have the same format, rather than repeating everything?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that'll help cut down on length, 👍

## can be used to require "main" packages.
# required = ["github.com/user/thing/cmd/thing"]

## "ignored" lists a set of packages (not projects) that are ignored when
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ignored when/ignored completely when/

## Optional: an alternate location (URL or import path) for the project's source
# source = "https://github.com/myfork/package.git"
## Optional, but recommended: the version constraint to enforce for the project.
## Only one of "branch", "version" or "revision" can be specified.
# version = "1.0.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a constraint string like ">=0.4.0, <1.0.0" or a specific version it has to be? Might be helpful to briefly describe these in here, or add a second line to make this behavior clear

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be either (though note that when #225 goes in, 1.0.0 will be interpreted as ^1.0.0). It can also specify an entirely non-semver tag for a literal match.

We need a more formal writeup of all of these rules. The examples here should really just be terse, and point to said writeup.

Injecting the comments at the bottom is suboptimal, as it means that
additional dependencies injected by later `dep ensure` calls (under
the new spec) will be separated from the original `init` set.

This seems slightly annoying now, but once we add a flag to allow
bypassing example injection, it'll be less of a problem.
txn_writer.go Outdated
const exampleTOML = `
## EXAMPLES & DOCS - safe to delete!
#
## Dependencies define constraints on how dependent projects should be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependencies define constraints on dependent projects. The bit about Gopkg.lock is a bit jargony and I don't think it adds anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's fair, i was trying to make more of a distinction than we really needed

txn_writer.go Outdated
const exampleToml = `
# Example:
const exampleTOML = `
## EXAMPLES & DOCS - safe to delete!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example (these lines may be deleted)

txn_writer.go Outdated
# source = "https://github.com/myfork/package.git"
## Optional, but recommended: the version constraint to enforce for the project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the optional but recommended one above the optional one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

txn_writer.go Outdated
# branch = "master"
# name = "github.com/vendor/package"
# Note: revision will depend on your repository type, i.e git, svc, bzr etc...
## Note: revision will depend on your repository type; git and hg have SHA1s,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note is unnecessary IMO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped it

txn_writer.go Outdated
#
## Dependencies define constraints on how dependent projects should be
## incorporated into Gopkg.lock. They are respected by dep whether
## this project is the current project, or if it's a dependency.
# [[dependencies]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps each line should precede its documentation. It might be clearer that way.

# [[dependencies]]
## The dependencies section defines constraints ...
# name = "..."
## The required name field specifies the root...

txn_writer.go Outdated
# revision = "abc123"
# version = "1.0.0"
#
## [[overrides]] follow the exact same structure as [[dependencies]], but supercede
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# [[overrides]]

??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, restructuring this. I dropped the section overall because it's duplicative of [[dependencies]], but i'm re-adding it because the comment text should actually be different.

@sdboyer
Copy link
Member Author

sdboyer commented Apr 28, 2017

Reorganized and fleshed out the text a bit more. Had to put the required and ignored elements up top, or they're actually being grouped in with the previous table array elem.

txn_writer.go Outdated
const exampleToml = `
# Example:
const exampleTOML = `
## EXAMPLE (these lines may be deleted)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please not shout? :-)

txn_writer.go Outdated
## project. Use it when your project needs a package it doesn't explicitly import -
## including "main" packages.
# required = ["github.com/user/thing/cmd/thing"]
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single blank please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, I introduced these to try to visually delineate between the groups of items, but now that their ordering is actually correct, can just rely on...yknow, TOML's rules 😄

txn_writer.go Outdated
const exampleTOML = `
## EXAMPLE (these lines may be deleted)
#
## "required" lists a set of packages (not projects) that must be included in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was suggesting in the previous round of comments was that the docs should be after the thing they document, which I know is different to how it works in Go code, but in this case we're looking at a config example so I think it makes some kind of sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how that makes sense with the [[dependencies]], where it looks more or less like a section header. But with I think it'd be more confusing to do that on individual values. I can't think of a commented config file I've seen that puts descriptive docs below the values they describe.

txn_writer.go Outdated
## Dependencies define constraints on dependent projects. They are respected by
## dep whether coming from the Gopkg.toml of the current project or a dependency.
#
## Required: the root import path of the project being constrained.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's easier to read if this is just an actual sentence.

The required name field specifies the root import path...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point - I'll see if I can rework the others, then. Mostly, I care about consistency

@sdboyer sdboyer merged commit 11b52a3 into golang:master Apr 28, 2017
@sdboyer
Copy link
Member Author

sdboyer commented Apr 28, 2017

@adg @fortytw2 @zellyn thanks for review!

@carolynvs carolynvs mentioned this pull request May 5, 2017
ibrasho pushed a commit to ibrasho-forks/dep that referenced this pull request May 10, 2017
Expand example Gopkg.toml text; always add on init
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants