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

Remove broken glob exclude patterns #742

Merged
merged 1 commit into from
Jan 24, 2020
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ flate2 = "1.0"
hex = "0.4"
ignore = "0.4.11"
git2 = "0.11"
globset = "0.4.4"
nextcloud_appinfo = "0.5.0"
nextcloud_appsignature = "0.4.0"
nextcloud_appstore = "0.6.0"
Expand Down
11 changes: 0 additions & 11 deletions src/config/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,18 @@ impl Into<AppConfig> for ParsedAppConfig {
#[derive(Debug)]
pub struct PackageConfig {
before_cmds: Vec<String>,
exclude: Vec<String>,
}

impl PackageConfig {
pub fn before_cmds(&self) -> &Vec<String> {
&self.before_cmds
}
pub fn exclude(&self) -> &Vec<String> {
&self.exclude
}
}

impl Into<PackageConfig> for ParsedPackageConfig {
fn into(self) -> PackageConfig {
PackageConfig {
before_cmds: self.before_cmds.unwrap_or(vec![]),
exclude: self.exclude.unwrap_or(vec![]),
}
}
}
Expand All @@ -80,12 +75,6 @@ impl Default for PackageConfig {
fn default() -> Self {
PackageConfig {
before_cmds: vec![],
exclude: vec![
".git".to_owned(),
".gitignore".to_owned(),
"build".to_owned(),
"tests".to_owned(),
],
}
}
}
Expand Down
64 changes: 0 additions & 64 deletions src/packaging/exclude.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/packaging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use failure::Error;
mod archive;
mod artifacts;
mod commands;
mod exclude;
mod pipeline;

use crate::packaging::pipeline::App;
Expand Down
24 changes: 9 additions & 15 deletions src/packaging/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tempdir::TempDir;

use crate::config;
use crate::packaging::commands::{self, PackageCommands};
use crate::packaging::{archive, artifacts, exclude};
use crate::packaging::{archive, artifacts};

fn tmp_app_path(base: &Path, app_id: &str) -> PathBuf {
let mut buf = base.to_path_buf();
Expand Down Expand Up @@ -91,6 +91,9 @@ impl AppWithDependencies {
Some(config) => (config, false),
None => (config::app::AppConfig::default(), true),
};
if !default && !config.package().before_cmds().is_empty() {
bail!("The exclude array in krankerl.toml was removed in 0.12. Use a .nextcloudignore instead.")
}
let cmds = commands::CommandList::from(config.package());
cmds.execute(&tmp_app_path(&self.tmp_dir.path(), self.app_info.id()))?;

Expand All @@ -99,30 +102,26 @@ impl AppWithDependencies {
} else {
println!("App built");
}
Ok(BuiltApp::new(self, config))
Ok(BuiltApp::new(self))
}
}

pub struct BuiltApp {
app: App,
app_info: AppInfo,
config: config::app::AppConfig,
tmp_dir: TempDir,
}

impl BuiltApp {
pub fn new(with_deps: AppWithDependencies, config: config::app::AppConfig) -> Self {
pub fn new(with_deps: AppWithDependencies) -> Self {
BuiltApp {
app: with_deps.app,
app_info: with_deps.app_info,
config: config,
tmp_dir: with_deps.tmp_dir,
}
}

pub fn into_archive(self) -> Result<AppArchive, Error> {
let excludes = exclude::ExcludedFiles::new(self.config.package().exclude())?;

let mut compressed_archive_path = self.app.source_path.to_path_buf();
compressed_archive_path.push("build");
compressed_archive_path.push("artifacts");
Expand All @@ -138,7 +137,7 @@ impl BuiltApp {
{
let base = Path::new(self.app_info.id());

let file_list = build_file_list(&app_path, &excludes);
let file_list = build_file_list(&app_path);
let encoder = archive::build_app_archive(&base, &app_path, file_list, encoder)?;
encoder.finish()?;
}
Expand All @@ -158,8 +157,7 @@ impl BuiltApp {

let app_path = tmp_app_path(self.tmp_dir.path(), self.app_info.id());
{
let excludes = exclude::ExcludedFiles::new(self.config.package().exclude())?;
for entry in build_file_list(&app_path, &excludes) {
for entry in build_file_list(&app_path) {
if !entry.metadata().unwrap().is_dir() {
let entry_path = entry.path();
if let Some(normalized) = diff_paths(&entry_path, &app_path) {
Expand All @@ -179,16 +177,12 @@ impl BuiltApp {
}
}

fn build_file_list(build_path: &Path, excludes: &exclude::ExcludedFiles) -> Vec<DirEntry> {
fn build_file_list(build_path: &Path) -> Vec<DirEntry> {
WalkBuilder::new(build_path)
.standard_filters(false)
.add_custom_ignore_filename(".nextcloudignore")
.build()
.into_iter()
.filter(|e| match e {
Ok(entry) => !excludes.is_excluded(entry.path(), build_path),
Err(_) => false,
})
.map(|e| e.unwrap())
.collect()
}
Expand Down