Skip to content

Commit 048fde3

Browse files
committed
Remove deprecated config key and template filters
1 parent 2f68940 commit 048fde3

File tree

9 files changed

+5
-88
lines changed

9 files changed

+5
-88
lines changed

src/config/normalize.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Normalize a raw config from the file into a [`Config`].
22
33
use std::str;
4-
use std::str::FromStr;
54

65
use anyhow::{anyhow, bail, Context as ResultExt, Error, Result};
76
use indexmap::IndexMap;
@@ -83,31 +82,19 @@ fn normalize_plugin(
8382
remote,
8483
local,
8584
inline,
86-
mut proto,
85+
proto,
8786
reference,
8887
dir,
8988
uses,
9089
apply,
9190
profiles,
9291
hooks,
93-
mut rest,
92+
rest,
9493
} = raw_plugin;
9594

9695
let is_reference_some = reference.is_some();
9796
let is_gist_or_github = gist.is_some() || github.is_some();
9897

99-
// Handle some deprecated items :/
100-
if proto.is_none() {
101-
if let Some(protocol) = try_pop_toml_value(&mut rest, "protocol") {
102-
warnings.push(anyhow!(
103-
"use of deprecated config key: `plugins.{name}.protocol`, please use \
104-
`plugins.{name}.proto` instead",
105-
name = name,
106-
));
107-
proto = Some(protocol);
108-
}
109-
}
110-
11198
check_extra_toml(rest, |key| {
11299
warnings.push(anyhow!("unused config key: `plugins.{name}.{key}`"));
113100
});
@@ -217,23 +204,6 @@ impl Source {
217204
}
218205
}
219206

220-
/// Try and pop the TOML value from the table.
221-
fn try_pop_toml_value<T>(rest: &mut Option<toml::Value>, key: &str) -> Option<T>
222-
where
223-
T: FromStr,
224-
{
225-
if let Some(toml::Value::Table(table)) = rest {
226-
if let Some(toml::Value::String(s)) = table.get(key) {
227-
let result = s.parse().ok();
228-
if result.is_some() {
229-
table.remove(key);
230-
}
231-
return result;
232-
}
233-
}
234-
None
235-
}
236-
237207
/// Call the given function on all extra TOML keys.
238208
fn check_extra_toml<F>(rest: Option<toml::Value>, mut f: F)
239209
where

src/lock/script.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{Context as ResultExt, Error, Result};
1+
use anyhow::{Context as ResultExt, Result};
22
use once_cell::sync::Lazy;
33
use serde::Serialize;
44
use std::collections::BTreeMap;
@@ -18,7 +18,7 @@ struct ExternalData<'a> {
1818

1919
impl LockedConfig {
2020
/// Generate the script.
21-
pub fn script(&self, ctx: &Context, warnings: &mut Vec<Error>) -> Result<String> {
21+
pub fn script(&self, ctx: &Context) -> Result<String> {
2222
static USED_GET: Lazy<Mutex<bool>> = Lazy::new(|| Mutex::new(false));
2323

2424
let mut engine = upon::Engine::new();
@@ -105,14 +105,6 @@ impl LockedConfig {
105105
}
106106
}
107107

108-
if *USED_GET.lock().unwrap() {
109-
warnings.push(Error::msg(
110-
"use of deprecated filter `get` in [templates], please use the `?.` operator \
111-
instead.\nFor example: `{{ hooks | get: \"pre\" | nl }}` can be written `{{ \
112-
hooks?.pre | nl }}`",
113-
));
114-
}
115-
116108
Ok(script)
117109
}
118110
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn source(ctx: &Context, warnings: &mut Vec<Error>) -> Result<()> {
233233
};
234234

235235
let script = locked_config
236-
.script(ctx, warnings)
236+
.script(ctx)
237237
.context("failed to render source")?;
238238

239239
if to_path && locked_config.errors.is_empty() {

tests/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,6 @@ fn lock_and_source_hooks() -> io::Result<()> {
422422
Ok(())
423423
}
424424

425-
#[test]
426-
fn lock_and_source_deprecated_get_filter() -> io::Result<()> {
427-
let case = TestCase::load("deprecated_get_filter")?;
428-
case.run()?;
429-
check_sheldon_test(&case.dirs.data).unwrap();
430-
Ok(())
431-
}
432-
433425
#[test]
434426
fn directories_default() -> io::Result<()> {
435427
let dirs = TestDirs::default()?;

tests/testdata/deprecated_get_filter/lock.stderr

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/testdata/deprecated_get_filter/plugins.lock

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/testdata/deprecated_get_filter/plugins.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/testdata/deprecated_get_filter/source.stderr

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/testdata/deprecated_get_filter/source.stdout

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)