mirror of
https://github.com/casey/just.git
synced 2024-11-22 10:26:26 +03:00
Remove call to sed in justfile (#1078)
This commit is contained in:
parent
d7897b4510
commit
27cd8fd554
@ -1,3 +1 @@
|
||||
cognitive-complexity-threshold = 1337
|
||||
|
||||
doc-valid-idents = ["FreeBSD"]
|
||||
|
15
justfile
15
justfile
@ -48,15 +48,16 @@ man:
|
||||
view-man: man
|
||||
man man/just.1
|
||||
|
||||
version := `sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1`
|
||||
|
||||
# add git log messages to changelog
|
||||
changes:
|
||||
git log --pretty=format:%s >> CHANGELOG.md
|
||||
|
||||
check: actionlint fmt clippy test forbid
|
||||
check: fmt clippy test forbid
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
grep '^\[{{ version }}\]' CHANGELOG.md
|
||||
VERSION=`sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1`
|
||||
grep "^\[$VERSION\]" CHANGELOG.md
|
||||
cargo +nightly generate-lockfile -Z minimal-versions
|
||||
cargo ltest
|
||||
git checkout Cargo.lock
|
||||
@ -105,11 +106,7 @@ install-dev-deps:
|
||||
|
||||
# install system development dependencies with homebrew
|
||||
install-dev-deps-homebrew:
|
||||
brew tap "rhysd/actionlint" "https://github.com/rhysd/actionlint"
|
||||
brew install actionlint help2man shellcheck
|
||||
|
||||
actionlint:
|
||||
SHELLCHECK_OPTS='-e SC2006 -e SC2002 -e SC2050' actionlint
|
||||
brew install help2man
|
||||
|
||||
# everyone's favorite animate paper clip
|
||||
clippy:
|
||||
|
@ -1,3 +1,6 @@
|
||||
#![allow(clippy::unknown_clippy_lints)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use crate::common::*;
|
||||
|
||||
use Function::*;
|
||||
|
@ -91,7 +91,7 @@ impl<'src> Justfile<'src> {
|
||||
}
|
||||
|
||||
let dotenv = if config.load_dotenv {
|
||||
load_dotenv(&config, &self.settings, &search.working_directory)?
|
||||
load_dotenv(config, &self.settings, &search.working_directory)?
|
||||
} else {
|
||||
BTreeMap::new()
|
||||
};
|
||||
@ -129,7 +129,7 @@ impl<'src> Justfile<'src> {
|
||||
binary, arguments, ..
|
||||
} => {
|
||||
let mut command = if config.shell_command {
|
||||
let mut command = self.settings.shell_command(&config);
|
||||
let mut command = self.settings.shell_command(config);
|
||||
command.arg(binary);
|
||||
command
|
||||
} else {
|
||||
@ -168,7 +168,7 @@ impl<'src> Justfile<'src> {
|
||||
print!("{}", value);
|
||||
} else {
|
||||
return Err(Error::EvalUnknownVariable {
|
||||
suggestion: self.suggest_variable(&variable),
|
||||
suggestion: self.suggest_variable(variable),
|
||||
variable: variable.clone(),
|
||||
});
|
||||
}
|
||||
@ -261,7 +261,7 @@ impl<'src> Justfile<'src> {
|
||||
|
||||
let mut ran = BTreeSet::new();
|
||||
for (recipe, arguments) in grouped {
|
||||
self.run_recipe(&context, recipe, arguments, &dotenv, &search, &mut ran)?;
|
||||
self.run_recipe(&context, recipe, arguments, &dotenv, search, &mut ran)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -344,7 +344,7 @@ impl<'src> Justfile<'src> {
|
||||
}
|
||||
|
||||
let mut invocation = vec![recipe.name().to_owned()];
|
||||
for argument in arguments.iter().cloned() {
|
||||
for argument in arguments.iter().copied() {
|
||||
invocation.push(argument.to_owned());
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ where
|
||||
S: Serializer,
|
||||
K: Keyed<'src>,
|
||||
{
|
||||
serializer.serialize_str(&keyed.key())
|
||||
serializer.serialize_str(keyed.key())
|
||||
}
|
||||
|
||||
pub(crate) fn serialize_option<'src, S, K>(
|
||||
|
@ -174,7 +174,7 @@ impl<'src> Lexer<'src> {
|
||||
|
||||
/// Get current indentation
|
||||
fn indentation(&self) -> &'src str {
|
||||
self.indentation.last().cloned().unwrap()
|
||||
self.indentation.last().unwrap()
|
||||
}
|
||||
|
||||
/// Are we currently indented
|
||||
|
@ -1,5 +1,6 @@
|
||||
#![deny(clippy::all, clippy::pedantic)]
|
||||
#![allow(
|
||||
clippy::doc_markdown,
|
||||
clippy::enum_glob_use,
|
||||
clippy::if_not_else,
|
||||
clippy::missing_errors_doc,
|
||||
|
@ -15,7 +15,7 @@ pub(crate) fn load_dotenv(
|
||||
}
|
||||
|
||||
if let Some(path) = &config.dotenv_path {
|
||||
return load_from_file(config, settings, &path);
|
||||
return load_from_file(config, settings, path);
|
||||
}
|
||||
|
||||
let filename = config
|
||||
|
@ -56,6 +56,6 @@ impl<'src> Serialize for Name<'src> {
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(&self.lexeme())
|
||||
serializer.serialize_str(self.lexeme())
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ pub(crate) trait Node<'src> {
|
||||
impl<'src> Node<'src> for Ast<'src> {
|
||||
fn tree(&self) -> Tree<'src> {
|
||||
Tree::atom("justfile")
|
||||
.extend(self.items.iter().map(|item| item.tree()))
|
||||
.extend(self.warnings.iter().map(|warning| warning.tree()))
|
||||
.extend(self.items.iter().map(Node::tree))
|
||||
.extend(self.warnings.iter().map(Node::tree))
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ impl<'src> Node<'src> for UnresolvedRecipe<'src> {
|
||||
}
|
||||
|
||||
if !self.body.is_empty() {
|
||||
t.push_mut(Tree::atom("body").extend(self.body.iter().map(|line| line.tree())));
|
||||
t.push_mut(Tree::atom("body").extend(self.body.iter().map(Node::tree)));
|
||||
}
|
||||
|
||||
t
|
||||
@ -200,7 +200,7 @@ impl<'src> Node<'src> for Parameter<'src> {
|
||||
|
||||
impl<'src> Node<'src> for Line<'src> {
|
||||
fn tree(&self) -> Tree<'src> {
|
||||
Tree::list(self.fragments.iter().map(|fragment| fragment.tree()))
|
||||
Tree::list(self.fragments.iter().map(Node::tree))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
|
||||
expected: self
|
||||
.expected
|
||||
.iter()
|
||||
.cloned()
|
||||
.copied()
|
||||
.filter(|kind| *kind != ByteOrderMark)
|
||||
.collect::<Vec<TokenKind>>(),
|
||||
found: self.next()?.kind,
|
||||
@ -77,7 +77,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
|
||||
fn rest(&self) -> impl Iterator<Item = Token<'src>> + 'tokens {
|
||||
self.tokens[self.next..]
|
||||
.iter()
|
||||
.cloned()
|
||||
.copied()
|
||||
.filter(|token| token.kind != Whitespace)
|
||||
}
|
||||
|
||||
@ -654,10 +654,10 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
|
||||
};
|
||||
|
||||
Ok(Parameter {
|
||||
name,
|
||||
kind,
|
||||
default,
|
||||
export,
|
||||
kind,
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
|
||||
self.expect(BracketR)?;
|
||||
|
||||
Ok(Set {
|
||||
value: Setting::Shell(setting::Shell { command, arguments }),
|
||||
value: Setting::Shell(setting::Shell { arguments, command }),
|
||||
name,
|
||||
})
|
||||
} else {
|
||||
|
@ -87,7 +87,7 @@ impl<'src: 'run, 'run> RecipeResolver<'src, 'run> {
|
||||
|
||||
if let Some(resolved) = self.resolved_recipes.get(name) {
|
||||
// dependency already resolved
|
||||
dependencies.push(Rc::clone(&resolved));
|
||||
dependencies.push(Rc::clone(resolved));
|
||||
} else if stack.contains(&name) {
|
||||
let first = stack[0];
|
||||
stack.push(first);
|
||||
@ -97,7 +97,7 @@ impl<'src: 'run, 'run> RecipeResolver<'src, 'run> {
|
||||
circle: stack
|
||||
.iter()
|
||||
.skip_while(|name| **name != dependency.recipe.lexeme())
|
||||
.cloned()
|
||||
.copied()
|
||||
.collect(),
|
||||
}),
|
||||
);
|
||||
|
@ -46,7 +46,7 @@ impl<'src, 'run> Scope<'src, 'run> {
|
||||
}
|
||||
|
||||
pub(crate) fn names(&self) -> impl Iterator<Item = &str> {
|
||||
self.bindings.keys().cloned()
|
||||
self.bindings.keys().copied()
|
||||
}
|
||||
|
||||
pub(crate) fn parent(&self) -> Option<&'run Scope<'src, 'run>> {
|
||||
|
@ -18,7 +18,7 @@ impl Search {
|
||||
) -> SearchResult<Self> {
|
||||
match search_config {
|
||||
SearchConfig::FromInvocationDirectory => {
|
||||
let justfile = Self::justfile(&invocation_directory)?;
|
||||
let justfile = Self::justfile(invocation_directory)?;
|
||||
|
||||
let working_directory = Self::working_directory_from_justfile(&justfile)?;
|
||||
|
||||
@ -68,7 +68,7 @@ impl Search {
|
||||
) -> SearchResult<Self> {
|
||||
match search_config {
|
||||
SearchConfig::FromInvocationDirectory => {
|
||||
let working_directory = Self::project_root(&invocation_directory)?;
|
||||
let working_directory = Self::project_root(invocation_directory)?;
|
||||
|
||||
let justfile = working_directory.join(DEFAULT_JUSTFILE_NAME);
|
||||
|
||||
@ -174,7 +174,7 @@ impl Search {
|
||||
io_error,
|
||||
directory: directory.to_owned(),
|
||||
})?;
|
||||
for project_root_child in PROJECT_ROOT_CHILDREN.iter().cloned() {
|
||||
for project_root_child in PROJECT_ROOT_CHILDREN.iter().copied() {
|
||||
if entry.file_name() == project_root_child {
|
||||
return Ok(directory.to_owned());
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ impl Subcommand {
|
||||
Self::changelog();
|
||||
return Ok(());
|
||||
}
|
||||
Completions { shell } => return Self::completions(&shell),
|
||||
Completions { shell } => return Self::completions(shell),
|
||||
Init => return Self::init(config),
|
||||
_ => {}
|
||||
}
|
||||
@ -59,7 +59,7 @@ impl Subcommand {
|
||||
|
||||
let src = loader.load(&search.justfile)?;
|
||||
|
||||
let tokens = Lexer::lex(&src)?;
|
||||
let tokens = Lexer::lex(src)?;
|
||||
let ast = Parser::parse(&tokens)?;
|
||||
let justfile = Analyzer::analyze(ast.clone())?;
|
||||
|
||||
@ -74,16 +74,16 @@ impl Subcommand {
|
||||
Self::choose(config, justfile, &search, overrides, chooser.as_deref())?;
|
||||
}
|
||||
Command { overrides, .. } | Evaluate { overrides, .. } => {
|
||||
justfile.run(config, &search, overrides, &[])?
|
||||
justfile.run(config, &search, overrides, &[])?;
|
||||
}
|
||||
Dump => Self::dump(config, ast, justfile)?,
|
||||
Format => Self::format(config, &search, &src, ast)?,
|
||||
Format => Self::format(config, &search, src, ast)?,
|
||||
List => Self::list(config, justfile),
|
||||
Run {
|
||||
arguments,
|
||||
overrides,
|
||||
} => justfile.run(config, &search, overrides, arguments)?,
|
||||
Show { ref name } => Self::show(config, &name, justfile)?,
|
||||
Show { ref name } => Self::show(config, name, justfile)?,
|
||||
Summary => Self::summary(config, justfile),
|
||||
Variables => Self::variables(justfile),
|
||||
Changelog | Completions { .. } | Edit | Init => unreachable!(),
|
||||
@ -107,7 +107,7 @@ impl Subcommand {
|
||||
.public_recipes(config.unsorted)
|
||||
.iter()
|
||||
.filter(|recipe| recipe.min_arguments() == 0)
|
||||
.cloned()
|
||||
.copied()
|
||||
.collect::<Vec<&Recipe<Dependency>>>();
|
||||
|
||||
if recipes.is_empty() {
|
||||
@ -121,7 +121,7 @@ impl Subcommand {
|
||||
|
||||
let result = justfile
|
||||
.settings
|
||||
.shell_command(&config)
|
||||
.shell_command(config)
|
||||
.arg(&chooser)
|
||||
.current_dir(&search.working_directory)
|
||||
.stdin(Stdio::piped())
|
||||
@ -132,8 +132,8 @@ impl Subcommand {
|
||||
Ok(child) => child,
|
||||
Err(io_error) => {
|
||||
return Err(Error::ChooserInvoke {
|
||||
shell_binary: justfile.settings.shell_binary(&config).to_owned(),
|
||||
shell_arguments: justfile.settings.shell_arguments(&config).join(" "),
|
||||
shell_binary: justfile.settings.shell_binary(config).to_owned(),
|
||||
shell_arguments: justfile.settings.shell_arguments(config).join(" "),
|
||||
chooser,
|
||||
io_error,
|
||||
});
|
||||
@ -365,7 +365,7 @@ impl Subcommand {
|
||||
}
|
||||
}
|
||||
|
||||
let max_line_width = cmp::min(line_widths.values().cloned().max().unwrap_or(0), 30);
|
||||
let max_line_width = cmp::min(line_widths.values().copied().max().unwrap_or(0), 30);
|
||||
|
||||
let doc_color = config.color.stdout().doc();
|
||||
print!("{}", config.list_heading);
|
||||
@ -392,7 +392,7 @@ impl Subcommand {
|
||||
doc_color.paint("#"),
|
||||
doc_color.paint(doc),
|
||||
padding = max_line_width
|
||||
.saturating_sub(line_widths.get(name).cloned().unwrap_or(max_line_width))
|
||||
.saturating_sub(line_widths.get(name).copied().unwrap_or(max_line_width))
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -87,11 +87,7 @@ impl Recipe {
|
||||
private: recipe.private,
|
||||
shebang: recipe.shebang,
|
||||
quiet: recipe.quiet,
|
||||
dependencies: recipe
|
||||
.dependencies
|
||||
.iter()
|
||||
.map(|dependency| Dependency::new(dependency))
|
||||
.collect(),
|
||||
dependencies: recipe.dependencies.iter().map(Dependency::new).collect(),
|
||||
lines: recipe.body.iter().map(Line::new).collect(),
|
||||
parameters: recipe.parameters.iter().map(Parameter::new).collect(),
|
||||
aliases,
|
||||
|
@ -89,7 +89,6 @@ impl<'table, V: Keyed<'table> + 'table> IntoIterator for &'table Table<'table, V
|
||||
type IntoIter = btree_map::Iter<'table, &'table str, V>;
|
||||
type Item = (&'table &'table str, &'table V);
|
||||
|
||||
#[must_use]
|
||||
fn into_iter(self) -> btree_map::Iter<'table, &'table str, V> {
|
||||
self.map.iter()
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ pub fn unindent(text: &str) -> String {
|
||||
let common_indentation = lines
|
||||
.iter()
|
||||
.filter(|line| !blank(line))
|
||||
.cloned()
|
||||
.copied()
|
||||
.map(indentation)
|
||||
.fold(
|
||||
None,
|
||||
|
@ -146,7 +146,7 @@ impl Test {
|
||||
|
||||
pub(crate) fn tree(self, mut tree: Tree) -> Self {
|
||||
tree.map(|_name, content| unindent(content));
|
||||
tree.instantiate(&self.tempdir.path()).unwrap();
|
||||
tree.instantiate(self.tempdir.path()).unwrap();
|
||||
self
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user