You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keep ".git" file in in --cleanDestinationDir #6261 was introducing a fix for the .gitfile in order to work correctly with git worktrees and submodules. Closed because of the Stale bot but it looks like it was still kept into consideration since @bep kept moving it among milestones after that.
However this wouldn't solve my issue since .domains and _redirects files would still be deleted.
Usecase
I'm using Codeberg Pages to host my website, you can find the repostitory at https://codeberg.org/ilovelinux/pages
I have two branches:
main: hugo projectpages: hugo build (output ofpublic/)Since I'm using Codeberg Pages with a custom domain, I also need a
.domainsfile1 to be pushed in thepagesbranch.When I
static/directory.mainbranch.public/folder using a git worktree of thepagesbranch.hugo build --cleanDestinationDir.I need
.gitfile created bygit worktree2..domainsfile used by Codeberg Pages in order to allow custom domains1._redirectsfile for redirects (however I'm not using it yet)3.Instead
Proposal
Add a configuration field to list relative file paths to
public/that should be retained when using--cleanDestinationDir.Example
Files retained:
public/.gitpublic/.domainspublic/_redirectspublic/foo/bar/.mysecretfileNote
I'm not suggesting to use
filesToRetainas configuration field, but I couldn't think of a better name.Notes
Important
--cleanDestinationDirdoes nothing when when thestatic/directory doesn't exist since its value is used inside thecopyStaticTofunction.hugo/commands/hugobuilder.go
Line 481 in c4bbc28
Workaround
Warning
This approach is error-prone.
I implemented a workaround in my Makefile that:
.domainsfile.Related issues & PR
.gitfolder being deleted.Fixed thanks to:
cleanDestinationDirKeepDotFolder#3210..gitfile of a submodule4 being deleted. Closed because it was considered a discussion..gitfile in order to work correctly with git worktrees and submodules. Closed because of the Stale bot but it looks like it was still kept into consideration since @bep kept moving it among milestones after that.However this wouldn't solve my issue since
.domainsand_redirectsfiles would still be deleted.Footnotes
https://docs.codeberg.org/codeberg-pages/using-custom-domain/ ↩ ↩2
https://git-scm.com/docs/git-worktree#_details ↩
https://docs.codeberg.org/codeberg-pages/redirects/ ↩
https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-absorbgitdirs ↩