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

commands: Added new option cleanDestinationDirKeepDotFolder #3210

Merged
merged 4 commits into from
Mar 21, 2017

Conversation

eamonnmcevoy
Copy link
Contributor

Add a new option to ignore 'dot' folders when deleting files in destination dir.

Fixes #3208

Add a new option to ignore 'dot' folders when deleting files in destination dir.

Fixes gohugoio#3208
@eamonnmcevoy
Copy link
Contributor Author

relates to: #3202

commands/hugo.go Outdated

if c.Cfg.GetBool("cleanDestinationDirKeepDotFolders") {
syncer.DeleteFilter = func(f os.FileInfo) bool {
return f.IsDir() && len(f.Name()) > 0 && string(f.Name()[0]) == "."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strings.HasPrefix(f.Name(), ".")

@@ -21,37 +21,38 @@ hugo benchmark
### Options

```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All doc below /commands is autogenerated so no need to edit it by hand.

commands/hugo.go Outdated
@@ -578,9 +580,16 @@ func (c *commandeer) copyStatic() error {
syncer.DestFs = c.Fs.Destination
// Now that we are using a unionFs for the static directories
// We can effectively clean the publishDir on initial sync
syncer.Delete = c.Cfg.GetBool("cleanDestinationDir")
syncer.Delete = c.Cfg.GetBool("cleanDestinationDir") || c.Cfg.GetBool("cleanDestinationDirKeepDotFolders")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have enough flag.

I would say that having a cleanDestinationDir command that also deleted hidden folders ("." files) was a surprise for many. So I suggest we just make this the new default and make sure to document it. People who want to remove the entire folder can use rm -rf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I'm not sure where to update the documentation, do I just update commands/hugo.go?

ln:215:
cmd.Flags().Bool("cleanDestinationDir", false, "Remove files from destination not found in static directories. Folders beginning with "." are ignored")

@github-actions
Copy link

This pull request 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 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants