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/pkgsite/cmd/frontend: unable to git-fetch remote-go-repo after git-init due to branch-name conflict #63254

Closed
aslatter opened this issue Sep 27, 2023 · 6 comments

Comments

@aslatter
Copy link

aslatter commented Sep 27, 2023

What version of Go are you using (go version)?

$ go version
go version go1.21.1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

N/A

What did you do?

I am attempting to use a locally-hosted instance of pkgsite in "direct proxy mode":

$ go run ./cmd/frontend --host :8080 --direct_proxy=true --proxy_url=http://localhost:3000

When I make a request for a stdlib package (io or log or the builtin package) pkgsite attempts to check-out the Go release corresponding to the tag requested using the git command-line tool and generate godocs from the git-checkout.

The commands executed are roughly equivalent to the following shell commands:

cd $(mktemp -d)
git init
git fetch --depth=1 -- https://go.googlesource.com/go refs/tags/go1.21.1:main
git checkout main

If the user has their default-git-branch configured to be 'main', the git-fetch operation conflicts with the working-copy created by 'git-init':

fatal: refusing to fetch into branch 'refs/heads/main' checked out at '/tmp/tmp.dXnQ9kxLPj'

A "real" containerized deployment is unlikely to run in to this, as it would be using the default "master" for the "git init".

What did you expect to see?

What did you see instead?

@gopherbot gopherbot added this to the Unreleased milestone Sep 27, 2023
@aslatter
Copy link
Author

My mistake - I have the default-branch-name over-ridden in my git configs.

This wouldn't be a real issue in a containerized deployment using default git-configs.

@bcmills
Copy link
Contributor

bcmills commented Sep 27, 2023

Ideally the git commands should be independent of global git config settings.

In the scripts in https://cs.opensource.google/go/go/+/master:src/cmd/go/testdata/vcstest/git/ I controlled for the user's default branch name by running git branch -m master after initializing the repo. Would that work for pkgsite too?

@hyangah
Copy link
Contributor

hyangah commented Oct 5, 2023

The relevant code place is https://github.com/golang/pkgsite/blob/14233af499055be3ba3fe6816af8e7d4a4efa9ad/internal/stdlib/gorepo.go#L32

However, with all the released go and toolchains officially in the module proxy (to support the forwards compatibility), I wonder if invoking git is really necessary...

@hyangah hyangah modified the milestones: Unreleased, pkgsite/unplanned Oct 5, 2023
@gopherbot
Copy link

Change https://go.dev/cl/540635 mentions this issue: internal/stdlib: pass -f to git fetch in remoteGoRepo.clone

gopherbot pushed a commit to golang/pkgsite that referenced this issue Nov 8, 2023
remoteGoRepo.clone inits a repo and then tries to fetch into the
"main" branch of the repo. But if the user's settings are for the
default branch to be called main, main will already exist and the
fetch command will fail. The -f flag will cause the command to do the
fetch even though the branch already exists.

For golang/go#63254
For golang/go#63744

Change-Id: I33f414654088a67eae4bfa70424d0dc6c34903f0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/540635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
@matloob
Copy link
Contributor

matloob commented Nov 13, 2023

@aslatter Could you verify if the issue is fixed on head or if it's still occurring for you?

@aslatter
Copy link
Author

Looks good to me.

Now,

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants