Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: mod tidy -go=1.17 should move indirect dependencies to the second require part [1.17 backport] #47756

Closed
gopherbot opened this issue Aug 17, 2021 · 6 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge GoCommand cmd/go
Milestone

Comments

@gopherbot
Copy link

@jayconrod requested issue #47733 to be considered for backport to the next 1.17 minor release.

@gopherbot Please backport to 1.17. This is annoying behavior in a new feature, and the fix shouldn't be very disruptive.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Aug 17, 2021
@gopherbot gopherbot added this to the Go1.17.1 milestone Aug 17, 2021
@mknyszek mknyszek added the GoCommand cmd/go label Aug 18, 2021
@bcmills bcmills added the CherryPickApproved Used during the release process for point releases label Sep 8, 2021
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Sep 8, 2021
@jayconrod
Copy link
Contributor

Some work is still needed on the upstream issue, so this will likely slip to 1.17.2.

@jayconrod jayconrod modified the milestones: Go1.17.1, Go1.17.2 Sep 9, 2021
@gopherbot
Copy link
Author

Change https://golang.org/cl/351317 mentions this issue: [release-branch.go1.17] modfile: in SetRequireSeparateIndirect, arrange requirements consistently

@gopherbot
Copy link
Author

Change https://golang.org/cl/351318 mentions this issue: [release-branch.go1.17] modfile: in SetRequireSeparateIndirect, convert lines to blocks

gopherbot pushed a commit to golang/mod that referenced this issue Sep 22, 2021
…ge requirements consistently

SetRequireSeparateIndirect now makes a stronger attempt to keep
automatically added requirements in two blocks: one containing only
direct requirements and one containing only indirect
requirements. SetRequireSeparateIndirect will find or add these two
blocks (commented blocks are left alone). New requirements are added
to one of these two blocks. Existing requirements may be moved between
these two blocks if their markings change.

SetRequireSeparateIndirect attempts to preserve existing structure in
the file by not adding requirements to or moving requirements from
blocks with block-level comments and blocks other than the last
uncommented direct-only and indirect-only block.

As an exception to aid with migration, if the file contains a single
uncommented block of requirements (as would the be the case if the
user started with a 1.16 go.mod file, changed the go directive to
1.17, then ran 'go mod tidy'), SetRequireSeparateIndirect will split
the block into direct-only and indirect-only blocks.

This is a change in behavior, but it has no semantic effect, and it
should result in cleaner, more stable go.mod files.

For golang/go#47756

Change-Id: Ifa20bb084c6bdaf1e00140600380857de8afa320
Reviewed-on: https://go-review.googlesource.com/c/mod/+/343431
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit 4be982b)
Reviewed-on: https://go-review.googlesource.com/c/mod/+/351317
gopherbot pushed a commit to golang/mod that referenced this issue Sep 22, 2021
…rt lines to blocks

When reading go.mod, SetRequireSeparateIndirect will insert new
requirements into the last uncommented direct-only or indirect-only
block OR line. If the last such statement is a line,
SetRequireSeparateIndirect converts it to a block before inserting new
requirements. Cleanup will convert it back to a line later if no
requirements are inserted.

For golang/go#47756

Change-Id: Id8ee3b0ce2d005488ddb3d9a5349115bd93938e7
Reviewed-on: https://go-review.googlesource.com/c/mod/+/348576
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit 37dd689)
Reviewed-on: https://go-review.googlesource.com/c/mod/+/351318
@gopherbot
Copy link
Author

Closed by merging 49f84bccfd3469cb3095201f7855641bcc8eb49a to release-branch.go1.17.

@gopherbot
Copy link
Author

Closed by merging 57376c6cd8fa43c48d17dc634e840bb3ccc5b257 to release-branch.go1.17.

@jayconrod jayconrod reopened this Sep 22, 2021
@gopherbot
Copy link
Author

Change https://golang.org/cl/351465 mentions this issue: [release-branch.go1.17] cmd/go: write go.mod requirements more consistently for go 1.17+

gopherbot pushed a commit that referenced this issue Sep 28, 2021
…tently for go 1.17+

If go.mod declares 1.17 or higher, when the go command rewrites go.mod
(for example, after 'go mod tidy'), it will be more consistent about
moving requirements in two blocks, one containing only direct
requirements, and one containing only indirect requirements.

The go command will not move requirements into or out of a block with
comments. It may still update versions and "// indirect" comments, and
it may delete unneeded requirements though.

Fixes #47756

Change-Id: Ia6fb3e302be53097893abf01aa7cea60ac7b069a
Reviewed-on: https://go-review.googlesource.com/c/go/+/343432
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 3c764ba)
Reviewed-on: https://go-review.googlesource.com/c/go/+/351465
TryBot-Result: Go Bot <gobot@golang.org>
@heschi heschi closed this as completed Sep 30, 2021
@golang golang locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge GoCommand cmd/go
Projects
None yet
Development

No branches or pull requests

5 participants