Skip to content

Commit

Permalink
feat: avoid copying gitignored files (#1000) (#1001)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
orhun and mergify[bot] committed Sep 30, 2023
1 parent cf64bb8 commit ab347ad
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/release_plz_core/src/copy_dir.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{fs, io, path::Path};

use anyhow::Context;
use ignore::{DirEntry, WalkBuilder};
use tracing::debug;
use walkdir::WalkDir;

use crate::strip_prefix::strip_prefix;

Expand Down Expand Up @@ -46,11 +46,10 @@ pub fn copy_dir(from: impl AsRef<Path>, to: impl AsRef<Path>) -> anyhow::Result<
#[tracing::instrument]
#[allow(clippy::filetype_is_file)] // we want to distinguish between files and symlinks
fn copy_directory(from: &Path, to: std::path::PathBuf) -> Result<(), anyhow::Error> {
for entry in WalkDir::new(from) {
for entry in WalkBuilder::new(from).hidden(false).ignore(true).build() {
let entry = entry.context("invalid entry")?;
let destination = destination_path(&to, &entry, from)?;

let file_type = entry.file_type();
let file_type = entry.file_type().context("unknown file type")?;
if file_type.is_dir() {
if destination == to {
continue;
Expand Down Expand Up @@ -86,7 +85,7 @@ fn copy_directory(from: &Path, to: std::path::PathBuf) -> Result<(), anyhow::Err

fn destination_path(
to: &Path,
entry: &walkdir::DirEntry,
entry: &DirEntry,
from: &Path,
) -> anyhow::Result<std::path::PathBuf> {
let mut dest_path = to.to_path_buf();
Expand Down

0 comments on commit ab347ad

Please sign in to comment.