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

x/tools: rewrite git history to remove accidental merge commit #43628

Closed
stamblerre opened this issue Jan 11, 2021 · 3 comments
Closed

x/tools: rewrite git history to remove accidental merge commit #43628

stamblerre opened this issue Jan 11, 2021 · 3 comments
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Soon This needs to be done soon. (regressions, serious bugs, outages) Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@stamblerre
Copy link
Contributor

Over the holidays, I accidentally merged golang/tools@2152f4e and then tried to revert it with golang/tools@6375436. This caused the gopls pseudoversions to start with v0.6.2 rather than v0.0.0 as before. We need to rewrite the Git history to remove these commits and restore the original pseudoversions.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jan 11, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jan 11, 2021
@cagedmantis cagedmantis added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 11, 2021
@cagedmantis
Copy link
Contributor

/cc @golang/release

@dmitshur dmitshur self-assigned this Jan 11, 2021
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. Soon This needs to be done soon. (regressions, serious bugs, outages) and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Jan 11, 2021
@dmitshur
Copy link
Contributor

We needed to rewrite the history of x/tools master branch so that the gopls/v0.6.1 tag would no longer be an ancestor (this is what was causing the pseudo-versions to start with v0.6.2-0.).

This is now done. The previous master commit golang/tools@e2f9c7f was replaced with commit golang/tools@1b1bb64, which prunes the merge CL and its revert but keeping the tree content unmodified.

Here's the complete log of how the rewrite was generated, for posterity:

$ cd $(mktemp -d)
$ git clone https://go.googlesource.com/tools && cd tools
Cloning into 'tools'...
[...]
tools $ git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.
tools $ git rev-parse HEAD
e2f9c7f1fc8e3456c71ab5b45a8220d3ae8e0aef
tools $ git merge-base --is-ancestor gopls/v0.6.1 HEAD && echo "problem" || echo "ok"
problem
tools $ git checkout -b rewrite-master master       
Switched to a new branch 'rewrite-master'
tools $ git diff master

# Rebase (interactively) on top of the latest commit on master
# branch before the merge CL.
tools $ git rebase -i 4a19ffb6e6422ea8855acc6b07cac1c44aa814e7

    (use this rebase script)

    # Rebase 4a19ffb6..e2f9c7f1 onto 4a19ffb6 (27 commands)
    #
    # Commands:
    # x, exec <command> = run command (the rest of the line) using shell
    # ...
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.

    # Drop the merge of gopls-release-branch.0.6 and its commits.
    #pick 72fbef54 internal/lsp/debug: update version number for v0.6.0
    #pick 2037813f gopls: update go.mod for v0.6.0-pre.1
    #pick c88dec5c [gopls-release-branch.0.6] internal/lsp: add titles to `go mod tidy` and update go.sum fixes
    #pick 1eed4871 gopls: update go.mod for gopls/v0.6.1-pre.1

    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' ee6d6aff)" git cherry-pick ee6d6aff # internal/lsp: restructure user options (CL 278433 continued)
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 0af0626a)" git cherry-pick 0af0626a # internal/lsp: save all possible keys for analyses, codelenses
    
    # Drop the revert.
    #pick 63754364 Revert "[gopls-release-branch.0.6] all: merge master into gopls-release-branch.0.6"
    
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 2dba1e4e)" git cherry-pick 2dba1e4e # go/analysis/passes/fieldalignment: add command
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 773b96fa)" git cherry-pick 773b96fa # internal/lsp: avoid panic during interface assertion
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' d8d6ddbe)" git cherry-pick d8d6ddbe # cmd/goyacc: double ACTSIZE, NSTATE and TEMPSTATE
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' b0ab187a)" git cherry-pick b0ab187a # gopls/internal/regtest: support multiple workspace folders
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 5e19fbb8)" git cherry-pick 5e19fbb8 # gopls: bump gofumpt to v0.1.0
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 79627818)" git cherry-pick 79627818 # gopls/doc: add additional information on CI in contributing.md
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' a548c3f4)" git cherry-pick a548c3f4 # gopls: update link to nvim-lspconfig gopls configuration
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' c658f992)" git cherry-pick c658f992 # internal/lsp/source: return all field funcs from outgoing callhierarchy
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 9ed45478)" git cherry-pick 9ed45478 # go/packages: remove -mod, -modfile flags from build flags for go version
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 465c416c)" git cherry-pick 465c416c # all: add copyright notices to files that are missing them
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' f9b4b89a)" git cherry-pick f9b4b89a # gopls/internal/regtest: skip regtests on android-amd64-emu
    
    # This CL is being dropped because it's no longer needed:
    # The change it makes is already in tree. It was fixing up
    # a change that the merge introduced, which is backed out.
    #pick 63752411 internal/lsp/debug: change hardcoded version to a constant
    
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 113979e3)" git cherry-pick 113979e3 # internal/lsp/cache: fix module paths in nested module error messages
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' a85a8cee)" git cherry-pick a85a8cee # internal/lsp/cache: fix panic in GOPATH mode
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 4ed967dd)" git cherry-pick 4ed967dd # Revert "go/analysis/passes/structtag: recognize multiple keys per tag"
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' a008e46a)" git cherry-pick a008e46a # gopls: use standard command doc comment format
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 551e49d8)" git cherry-pick 551e49d8 # gopls/internal/regtest: fix TestUnimportedCompletions
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' 7339b064)" git cherry-pick 7339b064 # gopls/internal/hooks: create included licenses text
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' e9a2c070)" git cherry-pick e9a2c070 # internal/lsp/cmd: add licenses command
    x GIT_COMMITTER_DATE="$(git show -s --pretty='%cd' e2f9c7f1)" git cherry-pick e2f9c7f1 # gopls/doc/emacs.md: describe configuration for eglot

Successfully rebased and updated refs/heads/rewrite-master.
tools $ git merge-base --is-ancestor gopls/v0.6.1 HEAD && echo "problem" || echo "ok"
ok
tools $ git diff master
tools $

Notably:

  • the unwanted gopls/v0.6.1 tag is no longer an ancestor of master branch
  • committer dates were preserved (since pseudo-versions use those)
  • the result is an identical tree as the original x/tools master

This issue is resolved now, and doing go get of the latest master commit (directly to VCS, bypassing module mirror for testing purposes) gives a v0.0.0 pseudo-version:

$ GO111MODULE=on GOPROXY=direct GOSUMDB=off go list -m -json golang.org/x/tools/gopls@master
{
	"Path": "golang.org/x/tools/gopls",
	"Version": "v0.0.0-20210108195828-1b1bb6453dc0",
	"Time": "2021-01-08T19:58:28Z"
}

In order to keep the previously published x/tools pseudo-versions valid, we created a new branch internal-branch.issue43628 that points to the previous x/tools master commit.

This works too:

$ GO111MODULE=on GOPROXY=direct GOSUMDB=off go list -m -json golang.org/x/tools@v0.0.0-20210108195828-e2f9c7f1fc8e 
{
	"Path": "golang.org/x/tools",
	"Version": "v0.0.0-20210108195828-e2f9c7f1fc8e",
	"Time": "2021-01-08T19:58:28Z"
}

I'll send a mail to golang-dev@ to notify anyone working on x/tools that a rewritten history is expected. No CLs were dropped during the rewrite and force push, so nothing needs to be re-sent. Closing.

@FiloSottile
Copy link
Contributor

One more for #26201.

@golang golang locked and limited conversation to collaborators Jan 12, 2022
@dmitshur dmitshur self-assigned this Jan 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Soon This needs to be done soon. (regressions, serious bugs, outages) Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants