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

Hugo includes deploy code even when built with "-tags nodeploy" #12009

Closed
flyn-org opened this issue Feb 7, 2024 · 2 comments · Fixed by #12011
Closed

Hugo includes deploy code even when built with "-tags nodeploy" #12009

flyn-org opened this issue Feb 7, 2024 · 2 comments · Fixed by #12011
Assignees
Milestone

Comments

@flyn-org
Copy link

flyn-org commented Feb 7, 2024

$ hugo version
hugo v0.121.1+extended linux/amd64 BuildDate=2024-02-06T18:00:00-06:00 VendorInfo=Fedora:0.121.1-1.fc39

Hugo includes optional code to support website deployment. This code brings in many dependencies, and Hugo provides an option to deactivate it (-tags nodeploy).

I maintain the official Hugo package for Fedora. Packaging the deploy code's dependencies has become difficult, so I now build the Hugo package without the deploy features. The trouble is that the Fedora packaging system automatically resolves dependencies by inspecting the imports found in Go code. I can partially address this by removing the "deploy" directory before building. However, config/allconfig/allconfig.go and config/allconfig/alldecoders.go import from the deploy directory regardless of the presence of the nodeploy tag.

Would it be possible to make conditional the use of deploy in allconfig.go and alldecoders.go with something like this

//go:build !nodeploy
// +build !nodeploy

?

That would go a long way to make packaging less fragile and more straight forward.

Here are my current steps, which might help illustrate what I am trying to describe:

  1. rm -rf deploy.
  2. Patch things with sed:
    • sed -i '/"github.com\/gohugoio\/hugo\/deploy"/d' config/allconfig/allconfig.go # Remove import.
    • sed -i 's/Deployment deploy.DeployConfig/Deployment bool/g' config/allconfig/allconfig.go # Replace use with bool.
    • sed -i '/"github.com\/gohugoio\/hugo\/deploy"/d' config/allconfig/alldecoders.go # Remove import.
    • sed -i 's/p.c.Deployment, err =/\/\/ p.c.Deployment, err =/g' config/allconfig/alldecoders.go # Comment out use.
  3. Run go build with -tags nodeploy.
  4. Run go test with -tags nodeploy.

Steps 1, 3, and 4 are fine. Step 2 is what I would like to avoid.

@bep bep removed the NeedsTriage label Feb 7, 2024
@bep bep self-assigned this Feb 7, 2024
@bep bep added this to the v0.123.0 milestone Feb 7, 2024
@bep
Copy link
Member

bep commented Feb 7, 2024

Would it be possible to make conditional the use of deploy in allconfig.go and alldecoders.go with something like this

We still need/want to load the config, but we should split the deploy config out into its own package, I guess.

bep added a commit to bep/hugo that referenced this issue Feb 7, 2024
Test:

```
go list -tags nodeploy ./... | grep deploy
```

Fixes gohugoio#12009
@bep bep closed this as completed in #12011 Feb 7, 2024
bep added a commit that referenced this issue Feb 7, 2024
Test:

```
go list -tags nodeploy ./... | grep deploy
```

Fixes #12009
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants