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

configurable support for symlinks #66

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub struct TemplateDefinition {
/// The directory in which the template files are.
/// Useful if a template has its own docs, README, CI and various files
pub directory: Option<String>,
/// Follow symlinks
#[serde(default)]
pub symlinks: bool,
/// Do not copy those directories/files
#[serde(default)]
pub ignore: Vec<String>,
Expand Down Expand Up @@ -200,6 +203,7 @@ mod tests {
name = "Test template"
description = "A description"
kickstart_version = 1
symlinks = false
Copy link
Owner

Choose a reason for hiding this comment

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

If we use an option, I'd rather have it follow_symlinks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

much more descriptive, agreed. I'll make that change.


[[variables]]
name = "project_name"
Expand Down
2 changes: 1 addition & 1 deletion src/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Template {
};

// And now generate the files in the output dir given
let walker = WalkDir::new(&start_path)
let walker = WalkDir::new(&start_path).follow_links(definition.symlinks)
Copy link
Owner

Choose a reason for hiding this comment

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

Should we follow them by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure of the original intent so I left it disabled by default, but I'm all for having it be the default case as long as it handles cycles during the walk and it doesn't effect Windows users. I'll test and makes sure that it doesn't introduce any issues there and if not make it the default.

Copy link
Owner

Choose a reason for hiding this comment

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

Initially the use case was for templates to be self contained, eg a git repo so there was no real need for symlinks

.into_iter()
.filter_entry(|e| {
// Ignore .git/ folder
Expand Down