Improve pre-publish check (#562)

- Ensure man page is up to date
- Build with summary feature
This commit is contained in:
Casey Rodarmor 2019-12-11 17:08:48 -08:00 committed by GitHub
parent 9eb867dd15
commit 49cd7f5a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 41 deletions

View File

@ -44,15 +44,18 @@ man:
--no-info \ --no-info \
target/debug/just \ target/debug/just \
> man/just.1 > man/just.1
view-man: man
man man/just.1 man man/just.1
version := `sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/v\1/p' Cargo.toml | head -1` version := `sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/v\1/p' Cargo.toml | head -1`
# publish to crates.io # publish to crates.io
publish-check: lint clippy test publish-check: lint clippy test man
git branch | grep '* master' git branch | grep '* master'
git diff --no-ext-diff --quiet --exit-code git diff --no-ext-diff --quiet --exit-code
grep {{version}} CHANGELOG.md grep {{version}} CHANGELOG.md
cargo build --features summary
cargo +nightly generate-lockfile -Z minimal-versions cargo +nightly generate-lockfile -Z minimal-versions
cargo test cargo test
git checkout Cargo.lock git checkout Cargo.lock

View File

@ -1,15 +1,18 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.11.
.TH JUST "1" "July 2019" "just 0.4.4" "JUST MANUAL" .TH JUST "1" "December 2019" "just 0.5.2" "JUST MANUAL"
.SH NAME .SH NAME
just \- save and run commands just \- save and run commands
.SH DESCRIPTION .SH DESCRIPTION
just 0.4.4 just 0.5.2
\- Please see https://github.com/casey/just for more information. \- Please see https://github.com/casey/just for more information.
.SS "USAGE:" .SS "USAGE:"
.IP .IP
just [FLAGS] [OPTIONS] [\-\-] [ARGUMENTS]... just [FLAGS] [OPTIONS] [\-\-] [ARGUMENTS]...
.SS "FLAGS:" .SS "FLAGS:"
.TP .TP
\fB\-\-clear\-shell\-args\fR
Clear shell arguments
.TP
\fB\-\-dry\-run\fR \fB\-\-dry\-run\fR
Print what just would do without doing it Print what just would do without doing it
.TP .TP
@ -17,7 +20,7 @@ Print what just would do without doing it
Print entire justfile Print entire justfile
.TP .TP
\fB\-e\fR, \fB\-\-edit\fR \fB\-e\fR, \fB\-\-edit\fR
Open justfile with $EDITOR Edit justfile with editor given by $VISUAL or $EDITOR, falling back to `vim`
.TP .TP
\fB\-\-evaluate\fR \fB\-\-evaluate\fR
Print evaluated variables Print evaluated variables
@ -25,9 +28,15 @@ Print evaluated variables
\fB\-\-highlight\fR \fB\-\-highlight\fR
Highlight echoed recipe lines in bold Highlight echoed recipe lines in bold
.TP .TP
\fB\-\-init\fR
Initialize new justfile in project root
.TP
\fB\-l\fR, \fB\-\-list\fR \fB\-l\fR, \fB\-\-list\fR
List available recipes and their arguments List available recipes and their arguments
.TP .TP
\fB\-\-no\-highlight\fR
Don't highlight echoed recipe lines in bold
.TP
\fB\-q\fR, \fB\-\-quiet\fR \fB\-q\fR, \fB\-\-quiet\fR
Suppress all output Suppress all output
.TP .TP
@ -53,11 +62,14 @@ Print colorful output [default: auto]
Use <JUSTFILE> as justfile. Use <JUSTFILE> as justfile.
.TP .TP
\fB\-\-set\fR <VARIABLE> <VALUE> \fB\-\-set\fR <VARIABLE> <VALUE>
Set <VARIABLE> to <VALUE> Override <VARIABLE> with <VALUE>
.TP .TP
\fB\-\-shell\fR <SHELL> \fB\-\-shell\fR <SHELL>
Invoke <SHELL> to run recipes [default: sh] Invoke <SHELL> to run recipes [default: sh]
.TP .TP
\fB\-\-shell\-arg\fR <SHELL\-ARG>...
Invoke shell with <SHELL\-ARG> as an argument [default: \fB\-cu]\fR
.TP
\fB\-s\fR, \fB\-\-show\fR <RECIPE> \fB\-s\fR, \fB\-\-show\fR <RECIPE>
Show information about <RECIPE> Show information about <RECIPE>
.HP .HP
@ -67,4 +79,4 @@ Use <WORKING\-DIRECTORY> as working directory. \fB\-\-justfile\fR must also be s
.SS "ARGS:" .SS "ARGS:"
.TP .TP
<ARGUMENTS>... <ARGUMENTS>...
The recipe(s) to run, defaults to the first recipe in the justfile Overrides and recipe(s) to run, defaulting to the first recipe in the justfile

View File

@ -12,18 +12,14 @@
//! ensuring that changes to just do not inadvertently break or //! ensuring that changes to just do not inadvertently break or
//! change the interpretation of existing justfiles. //! change the interpretation of existing justfiles.
use std::{ use std::{collections::BTreeMap, fs, io, path::Path};
collections::{BTreeMap, BTreeSet},
fs, io,
path::Path,
};
use crate::compiler::Compiler; use crate::compiler::Compiler;
mod full { mod full {
pub(crate) use crate::{ pub(crate) use crate::{
assignment::Assignment, expression::Expression, fragment::Fragment, justfile::Justfile, assignment::Assignment, dependency::Dependency, expression::Expression, fragment::Fragment,
line::Line, parameter::Parameter, recipe::Recipe, justfile::Justfile, line::Line, parameter::Parameter, recipe::Recipe, thunk::Thunk,
}; };
} }
@ -48,7 +44,7 @@ impl Summary {
for alias in justfile.aliases.values() { for alias in justfile.aliases.values() {
aliases aliases
.entry(alias.target.lexeme()) .entry(alias.target.name())
.or_insert_with(Vec::new) .or_insert_with(Vec::new)
.push(alias.name.to_string()); .push(alias.name.to_string());
} }
@ -60,13 +56,13 @@ impl Summary {
.map(|(name, recipe)| { .map(|(name, recipe)| {
( (
name.to_string(), name.to_string(),
Recipe::new(recipe, aliases.remove(name).unwrap_or_default()), Recipe::new(&recipe, aliases.remove(name).unwrap_or_default()),
) )
}) })
.collect(), .collect(),
assignments: justfile assignments: justfile
.assignments .assignments
.into_iter() .iter()
.map(|(name, assignment)| (name.to_string(), Assignment::new(assignment))) .map(|(name, assignment)| (name.to_string(), Assignment::new(assignment)))
.collect(), .collect(),
} }
@ -76,7 +72,7 @@ impl Summary {
#[derive(Eq, PartialEq, Hash, Ord, PartialOrd, Debug, Clone)] #[derive(Eq, PartialEq, Hash, Ord, PartialOrd, Debug, Clone)]
pub struct Recipe { pub struct Recipe {
pub aliases: Vec<String>, pub aliases: Vec<String>,
pub dependencies: BTreeSet<String>, pub dependencies: Vec<Dependency>,
pub lines: Vec<Line>, pub lines: Vec<Line>,
pub private: bool, pub private: bool,
pub quiet: bool, pub quiet: bool,
@ -85,18 +81,18 @@ pub struct Recipe {
} }
impl Recipe { impl Recipe {
fn new(recipe: full::Recipe, aliases: Vec<String>) -> Recipe { fn new(recipe: &full::Recipe, aliases: Vec<String>) -> Recipe {
Recipe { Recipe {
private: recipe.private, private: recipe.private,
shebang: recipe.shebang, shebang: recipe.shebang,
quiet: recipe.quiet, quiet: recipe.quiet,
dependencies: recipe dependencies: recipe
.dependencies .dependencies
.into_iter() .iter()
.map(|name| name.lexeme().to_string()) .map(|dependency| Dependency::new(dependency))
.collect(), .collect(),
lines: recipe.body.into_iter().map(Line::new).collect(), lines: recipe.body.iter().map(Line::new).collect(),
parameters: recipe.parameters.into_iter().map(Parameter::new).collect(), parameters: recipe.parameters.iter().map(Parameter::new).collect(),
aliases, aliases,
} }
} }
@ -110,11 +106,11 @@ pub struct Parameter {
} }
impl Parameter { impl Parameter {
fn new(parameter: full::Parameter) -> Parameter { fn new(parameter: &full::Parameter) -> Parameter {
Parameter { Parameter {
variadic: parameter.variadic, variadic: parameter.variadic,
name: parameter.name.lexeme().to_owned(), name: parameter.name.lexeme().to_owned(),
default: parameter.default.map(Expression::new), default: parameter.default.as_ref().map(Expression::new),
} }
} }
} }
@ -125,9 +121,9 @@ pub struct Line {
} }
impl Line { impl Line {
fn new(line: full::Line) -> Line { fn new(line: &full::Line) -> Line {
Line { Line {
fragments: line.fragments.into_iter().map(Fragment::new).collect(), fragments: line.fragments.iter().map(Fragment::new).collect(),
} }
} }
} }
@ -139,7 +135,7 @@ pub enum Fragment {
} }
impl Fragment { impl Fragment {
fn new(fragment: full::Fragment) -> Fragment { fn new(fragment: &full::Fragment) -> Fragment {
match fragment { match fragment {
full::Fragment::Text { token } => Fragment::Text { full::Fragment::Text { token } => Fragment::Text {
text: token.lexeme().to_owned(), text: token.lexeme().to_owned(),
@ -158,10 +154,10 @@ pub struct Assignment {
} }
impl Assignment { impl Assignment {
fn new(assignment: full::Assignment) -> Assignment { fn new(assignment: &full::Assignment) -> Assignment {
Assignment { Assignment {
exported: assignment.export, exported: assignment.export,
expression: Expression::new(assignment.expression), expression: Expression::new(&assignment.value),
} }
} }
} }
@ -188,22 +184,31 @@ pub enum Expression {
} }
impl Expression { impl Expression {
fn new(expression: full::Expression) -> Expression { fn new(expression: &full::Expression) -> Expression {
use full::Expression::*; use full::Expression::*;
match expression { match expression {
Backtick { contents, .. } => Expression::Backtick { Backtick { contents, .. } => Expression::Backtick {
command: contents.to_owned(), command: (*contents).to_owned(),
}, },
Call { Call { thunk } => match thunk {
function, full::Thunk::Nullary { name, .. } => Expression::Call {
arguments, name: name.lexeme().to_owned(),
} => Expression::Call { arguments: Vec::new(),
name: function.lexeme().to_owned(), },
arguments: arguments.into_iter().map(Expression::new).collect(), full::Thunk::Unary { name, arg, .. } => Expression::Call {
name: name.lexeme().to_owned(),
arguments: vec![Expression::new(arg)],
},
full::Thunk::Binary {
name, args: [a, b], ..
} => Expression::Call {
name: name.lexeme().to_owned(),
arguments: vec![Expression::new(a), Expression::new(b)],
},
}, },
Concatination { lhs, rhs } => Expression::Concatination { Concatination { lhs, rhs } => Expression::Concatination {
lhs: Box::new(Expression::new(*lhs)), lhs: Box::new(Expression::new(lhs)),
rhs: Box::new(Expression::new(*rhs)), rhs: Box::new(Expression::new(rhs)),
}, },
StringLiteral { string_literal } => Expression::String { StringLiteral { string_literal } => Expression::String {
text: string_literal.cooked.to_string(), text: string_literal.cooked.to_string(),
@ -211,7 +216,22 @@ impl Expression {
Variable { name, .. } => Expression::Variable { Variable { name, .. } => Expression::Variable {
name: name.lexeme().to_owned(), name: name.lexeme().to_owned(),
}, },
Group { contents } => Expression::new(*contents), Group { contents } => Expression::new(contents),
}
}
}
#[derive(Eq, PartialEq, Hash, Ord, PartialOrd, Debug, Clone)]
pub struct Dependency {
pub recipe: String,
pub arguments: Vec<Expression>,
}
impl Dependency {
fn new(dependency: &full::Dependency) -> Dependency {
Dependency {
recipe: dependency.recipe.name().to_owned(),
arguments: dependency.arguments.iter().map(Expression::new).collect(),
} }
} }
} }