From d1ce5188ee797d7d64b514b126041daca49d089b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 26 Oct 2018 02:09:00 +0200 Subject: [PATCH 1/9] Update rustc versions Rust 1.30 came out today, so we're updating the minimum version we depend on. Signed-off-by: Matthias Beyer --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b0a0af3..8a42a2e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: - bash ./scripts/branch-contains-no-tmp-commits - bash ./scripts/version-updated - language: rust - rust: 1.27.2 + rust: 1.28.0 cache: directories: - /home/travis/.cargo @@ -26,7 +26,7 @@ matrix: - cargo build --all --all-features -j 1 || exit 1 - cargo test --all --all-features -j 1 || exit 1 - language: rust - rust: 1.28.0 + rust: 1.29.2 cache: directories: - /home/travis/.cargo From 366ca62eb9c25cdbf12a2be807b645203b772acd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 26 Oct 2018 15:17:37 +0200 Subject: [PATCH 2/9] Update dependency: mdcat: 0.8 -> 0.11 --- lib/entry/libimagentryview/Cargo.toml | 2 +- lib/entry/libimagentryview/src/builtin/md.rs | 21 ++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/entry/libimagentryview/Cargo.toml b/lib/entry/libimagentryview/Cargo.toml index 635dfc80..e6236919 100644 --- a/lib/entry/libimagentryview/Cargo.toml +++ b/lib/entry/libimagentryview/Cargo.toml @@ -30,7 +30,7 @@ libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } libimagentryedit = { version = "0.9.0", path = "../../../lib/entry/libimagentryedit" } -mdcat = { version = "0.8", optional = true } +mdcat = { version = "0.11", optional = true } [dependencies.pulldown-cmark] version = "^0.1" diff --git a/lib/entry/libimagentryview/src/builtin/md.rs b/lib/entry/libimagentryview/src/builtin/md.rs index 83d247e9..ecaa0468 100644 --- a/lib/entry/libimagentryview/src/builtin/md.rs +++ b/lib/entry/libimagentryview/src/builtin/md.rs @@ -22,10 +22,9 @@ use std::io::Write; use libimagstore::store::Entry; use libimagrt::runtime::Runtime; -use mdcat::{ResourceAccess, Terminal, TerminalSize}; +use mdcat::{AnsiTerminal, ResourceAccess, TerminalSize}; use pulldown_cmark::Parser; use syntect::parsing::SyntaxSet; -use mdcat; use viewer::Viewer; use failure::Fallible as Result; @@ -34,7 +33,6 @@ use failure::Error; pub struct MarkdownViewer<'a> { rt: &'a Runtime<'a>, resource_access: ResourceAccess, - terminal: Terminal, termsize: TerminalSize, } @@ -43,7 +41,6 @@ impl<'a> MarkdownViewer<'a> { MarkdownViewer { rt, resource_access: ResourceAccess::LocalOnly, - terminal: Terminal::detect(), termsize: TerminalSize::detect().unwrap_or(TerminalSize { width: 80, height: 20, @@ -60,13 +57,15 @@ impl<'a> Viewer for MarkdownViewer<'a> { let base_dir = self.rt.rtp(); let syntax_set = SyntaxSet::load_defaults_newlines(); - mdcat::push_tty(sink, - self.terminal.clone(), - self.termsize.clone(), - parser, - base_dir, - self.resource_access.clone(), - syntax_set) + let mut term = AnsiTerminal::new(sink); + + ::mdcat::push_tty(&mut term, + self.termsize.clone(), + parser, + base_dir, + self.resource_access.clone(), + syntax_set) + .map_err(|e| e.compat()) .map_err(Error::from) } } From 4bc25c3b80432e0c454025989a6c51bfa66fb034 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 26 Oct 2018 16:39:21 +0200 Subject: [PATCH 3/9] Add sendemail-validate hook for checking signoffby lines Signed-off-by: Matthias Beyer --- ...ndemail-validate.signoffby-missing-warn.sh | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/hooks/sendemail-validate.signoffby-missing-warn.sh diff --git a/scripts/hooks/sendemail-validate.signoffby-missing-warn.sh b/scripts/hooks/sendemail-validate.signoffby-missing-warn.sh new file mode 100644 index 00000000..386571e2 --- /dev/null +++ b/scripts/hooks/sendemail-validate.signoffby-missing-warn.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# +# The following snippet can be used to _WARN_ if a Signed-off-by line is missing +# in the commit message of the patch +# +# Use +# +# git config sendemail.validate true +# +# and link this script to your git hooks folder to enable. +# + +GREEN='\e[0;32m' # Green +RED='\e[0;31m' # Red +NORMAL='\e[0m' # Text Reset + +GREPLINE="^Signed-off-by: $(git config user.name) <$(git config user.email)>" + +if [ "$(grep -c "$GREPLINE" "$1")" -lt 1 ]; then + echo -e >&2 "${RED}Missing Signed-off-by line.${NORMAL}\n" + + # To not only warn, but abort the patch sending, uncomment the next line + # exit 1 +else + echo -e >&2 "${GREEN}Signed-off-by line found.${NORMAL}\n" +fi + From d8d60fa62f0e5ecd82b233763c3290cf246a9c89 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 26 Oct 2018 16:38:14 +0200 Subject: [PATCH 4/9] Move hook to have right file name Signed-off-by: Matthias Beyer --- ...offby-missing-warn.sh => commit-msg.signoffby-missing-warn.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/hooks/{pre-commit.signoffby-missing-warn.sh => commit-msg.signoffby-missing-warn.sh} (100%) diff --git a/scripts/hooks/pre-commit.signoffby-missing-warn.sh b/scripts/hooks/commit-msg.signoffby-missing-warn.sh similarity index 100% rename from scripts/hooks/pre-commit.signoffby-missing-warn.sh rename to scripts/hooks/commit-msg.signoffby-missing-warn.sh From 43f91ebf3620fd511bb6c3f933ea7d6661c99573 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 26 Oct 2018 16:37:11 +0200 Subject: [PATCH 5/9] Do print properly Signed-off-by: Matthias Beyer --- scripts/hooks/commit-msg.signoffby-missing-warn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/hooks/commit-msg.signoffby-missing-warn.sh b/scripts/hooks/commit-msg.signoffby-missing-warn.sh index 470e6575..a60a1610 100644 --- a/scripts/hooks/commit-msg.signoffby-missing-warn.sh +++ b/scripts/hooks/commit-msg.signoffby-missing-warn.sh @@ -9,7 +9,7 @@ RED='\e[0;31m' # Red NORMAL='\e[0m' # Text Reset if [ "1" != "$(grep -c '^Signed-off-by: ' "$1")" ]; then - printf >&2 "%sMissing Signed-off-by line.%s\n" "$RED" "$NORMAL" + echo -e >&2 "${RED}Missing Signed-off-by line.${NORMAL}\n" # To not only warn, but abort the commit, uncomment the next line # exit 1 From 444498e13c4d4de098e2d5b355f9a2bfbb84d808 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 10 Oct 2018 22:43:22 +0200 Subject: [PATCH 6/9] Update nix expression --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index d91de623..0cf9b07f 100644 --- a/default.nix +++ b/default.nix @@ -1,7 +1,7 @@ { pkgs ? (import {}) }: let - env = with pkgs.latest.rustChannels.stable; [ + env = with pkgs.rustChannels.stable; [ rust cargo ]; From 1d97e36c935a50569118150c8337f02c49e86761 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 26 Oct 2018 23:17:42 +0200 Subject: [PATCH 7/9] Add more CLI validators Signed-off-by: Matthias Beyer --- lib/etc/libimagutil/src/cli_validators.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/etc/libimagutil/src/cli_validators.rs b/lib/etc/libimagutil/src/cli_validators.rs index e2e9c8a5..eb5cdd1e 100644 --- a/lib/etc/libimagutil/src/cli_validators.rs +++ b/lib/etc/libimagutil/src/cli_validators.rs @@ -42,6 +42,20 @@ pub fn is_integer>(s: A) -> Result<(), String> { i.map(|_| ()).map_err(|_| format!("Not an integer: {}", s.as_ref())) } +pub fn is_float>(s: A) -> Result<(), String> { + use std::str::FromStr; + + let i : Result = FromStr::from_str(s.as_ref()); + i.map(|_| ()).map_err(|_| format!("Not an float: {}", s.as_ref())) +} + +pub fn is_bool>(s: A) -> Result<(), String> { + use std::str::FromStr; + + let i : Result = FromStr::from_str(s.as_ref()); + i.map(|_| ()).map_err(|_| format!("Not an bool: {}", s.as_ref())) +} + pub fn is_url>(s: A) -> Result<(), String> { use url::Url; Url::parse(s.as_ref()).map(|_| ()).map_err(|_| format!("Not a URL: {}", s.as_ref())) From 0bae8980904a0c4253b9b4f0955f14476eda011c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 29 Oct 2018 23:39:32 +0100 Subject: [PATCH 8/9] Remove unused script Signed-off-by: Matthias Beyer --- scripts/new-crate.sh | 113 ------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 scripts/new-crate.sh diff --git a/scripts/new-crate.sh b/scripts/new-crate.sh deleted file mode 100644 index 103bddf2..00000000 --- a/scripts/new-crate.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash - -# Helper script to create a new crate in the imag workspace - -# 1. Creates a new crate -# 2. Adds the required crate meta information -# 3. Sets the version of the crate to the same version as libimagstore -# 4. Adds the crate to the top-level workspace - -if [[ "$1" == "-h" || "$1" == "--help" ]]; -then - echo "$0 [bin|lib] ./path/to/new/crate" - echo - echo "Execute _only_ from the top level of the repository" - exit 0 -fi - -crate_type="$1" -crate_location="$2" - -exit_if_empty() { - [[ -z "$1" ]] && { echo "$2 not passed"; exit 1; } -} - -exit_if_empty "$crate_type" "crate type" -exit_if_empty "$crate_location" "crate location" - -exists_cmd() { - command -v $1 || { echo "No $1 found"; exit 1; } -} - -exists_cmd "git" -exists_cmd "cargo" - -{ cat ./Cargo.toml 2>/dev/null | head -n 1 | grep -q "[workspace]"; } || { - echo "Not in root of repository as it seems. Exiting"; - exit 1; -} - -[[ "$crate_type" == "lib" || "$crate_type" == "bin" ]] || { - echo "Invalid crate type, use 'lib' or 'bin'"; - exit 1; -} - -if [[ -e "$crate_location" ]]; then - echo "Crate exists: $crate_location" - exit 1; -fi - -IFS=/ read -ra crate_name_parts <<< "$crate_location" -crate_name="${crate_name_parts[-1]}" - -if [[ "$crate_type" == "lib" ]]; -then - crate_description="Library for the imag core distribution" -else if [[ "$crate_type" == "bin" ]]; then - crate_description="Part of the imag core distribution: $crate_name command" -fi - -git_name="$(git config user.name)" -git_email="$(git config user.email)" - -store="lib/core/libimagstore/Cargo.toml" -crate_version=$(grep -m 1 version $store | cut -d '"' -f 2) - -echo "Crate type: $crate_type" -echo "Crate location: $crate_location" -echo "Crate name: $crate_name" -echo "Crate version: $crate_version" -echo "Crate description: $crate_description" -echo "Crate author: $git_name <$git_email>" - -echo "Not doing anything as this script is not ready yet." -echo "Exiting now" -exit 1 - -pushd "$(dirname $crate_location)" -crate new --${crate_type} $crate_name - -cat < ./$crate_name/Cargo.toml -[package] -name = "$crate_name" -version = "$crate_version" -authors = ["$git_name <$git_email>"] - -description = "$crate_description" - -keywords = ["imag", "PIM", "personal", "information", "management"] -readme = "../../../README.md" -license = "LGPL-2.1" - -documentation = "https://imag-pim.org/doc/" -repository = "https://github.com/matthiasbeyer/imag" -homepage = "http://imag-pim.org" - -[badges] -travis-ci = { repository = "matthiasbeyer/imag" } -is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } -is-it-maintained-open-issues = { repository = "matthiasbeyer/imag" } -maintenance = { status = "actively-developed" } - -[dependencies] - -EOS - -echo "Cargo.toml written. Please make sure that the README has the right path!" -popd - -git add ${crate_location}/* - -sed -i "$ s/]/ \"${crate_location}\",\n]/" Cargo.toml -echo "Top-level Cargo.toml modified. Please sort crate list manually!" - From 21927d422582d82070eb58edc46d5c31bbc79b4e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 7 Oct 2018 10:00:56 +0200 Subject: [PATCH 9/9] imag build script: Update available commands --- bin/core/imag/build.rs | 97 ++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/bin/core/imag/build.rs b/bin/core/imag/build.rs index a7a4db21..fe2766b1 100644 --- a/bin/core/imag/build.rs +++ b/bin/core/imag/build.rs @@ -74,29 +74,31 @@ macro_rules! build_subcommand { // Actually generates the module. gen_mods_buildui!( - ("../../../bin/core/imag-annotate/src/ui.rs", imagannotate), - ("../../../bin/core/imag-diagnostics/src/ui.rs", imagdiagnostics), - ("../../../bin/core/imag-edit/src/ui.rs", imagedit), - ("../../../bin/core/imag-git/src/ui.rs", imaggit), - ("../../../bin/core/imag-gps/src/ui.rs", imaggps), - ("../../../bin/core/imag-grep/src/ui.rs", imaggrep), - ("../../../bin/core/imag-ids/src/ui.rs", imagids), - ("../../../bin/core/imag-init/src/ui.rs", imaginit), - ("../../../bin/core/imag-link/src/ui.rs", imaglink), - ("../../../bin/core/imag-mv/src/ui.rs", imagmv), - ("../../../bin/core/imag-ref/src/ui.rs", imagref), - ("../../../bin/core/imag-store/src/ui.rs", imagstore), - ("../../../bin/core/imag-tag/src/ui.rs", imagtag), - ("../../../bin/core/imag-view/src/ui.rs", imagview) - ("../../../bin/domain/imag-bookmark/src/ui.rs", imagbookmark), - ("../../../bin/domain/imag-contact/src/ui.rs", imagcontact), - ("../../../bin/domain/imag-diary/src/ui.rs", imagdiary), - ("../../../bin/domain/imag-habit/src/ui.rs", imaghabit), - ("../../../bin/domain/imag-log/src/ui.rs", imaglog), - ("../../../bin/domain/imag-mail/src/ui.rs", imagmail), - ("../../../bin/domain/imag-notes/src/ui.rs", imagnotes), - ("../../../bin/domain/imag-timetrack/src/ui.rs", imagtimetrack), - ("../../../bin/domain/imag-todo/src/ui.rs", imagtodo), + ("../../../bin/core/imag-annotate/src/ui.rs" , imagannotate) , + ("../../../bin/core/imag-category/src/ui.rs" , imagcategory) , + ("../../../bin/core/imag-diagnostics/src/ui.rs" , imagdiagnostics) , + ("../../../bin/core/imag-edit/src/ui.rs" , imagedit) , + ("../../../bin/core/imag-git/src/ui.rs" , imaggit) , + ("../../../bin/core/imag-gps/src/ui.rs" , imaggps) , + ("../../../bin/core/imag-grep/src/ui.rs" , imaggrep) , + ("../../../bin/core/imag-ids/src/ui.rs" , imagids) , + ("../../../bin/core/imag-init/src/ui.rs" , imaginit) , + ("../../../bin/core/imag-link/src/ui.rs" , imaglink) , + ("../../../bin/core/imag-mv/src/ui.rs" , imagmv) , + ("../../../bin/core/imag-ref/src/ui.rs" , imagref) , + ("../../../bin/core/imag-store/src/ui.rs" , imagstore) , + ("../../../bin/core/imag-tag/src/ui.rs" , imagtag) , + ("../../../bin/core/imag-view/src/ui.rs" , imagview) , + ("../../../bin/domain/imag-bookmark/src/ui.rs" , imagbookmark) , + ("../../../bin/domain/imag-contact/src/ui.rs" , imagcontact) , + ("../../../bin/domain/imag-diary/src/ui.rs" , imagdiary) , + ("../../../bin/domain/imag-habit/src/ui.rs" , imaghabit) , + ("../../../bin/domain/imag-log/src/ui.rs" , imaglog) , + ("../../../bin/domain/imag-mail/src/ui.rs" , imagmail) , + ("../../../bin/domain/imag-notes/src/ui.rs" , imagnotes) , + ("../../../bin/domain/imag-timetrack/src/ui.rs" , imagtimetrack) , + ("../../../bin/domain/imag-todo/src/ui.rs" , imagtodo) , + ("../../../bin/domain/imag-wiki/src/ui.rs" , imagwiki) , ); fn main() { @@ -107,29 +109,31 @@ fn main() { &version[..], "imag") // and add all the subapps as subcommands. - .subcommand(build_subcommand!("annotate", imagannotate, version)) - .subcommand(build_subcommand!("diagnostics", imagdiagnostics, version)) - .subcommand(build_subcommand!("edit", imagedit, version)) - .subcommand(build_subcommand!("git", imaggit, version)) - .subcommand(build_subcommand!("gps", imaggps, version)) - .subcommand(build_subcommand!("grep", imaggrep, version)) - .subcommand(build_subcommand!("ids", imagids, version)) - .subcommand(build_subcommand!("init", imaginit, version)) - .subcommand(build_subcommand!("link", imaglink, version)) - .subcommand(build_subcommand!("mv", imagmv, version)) - .subcommand(build_subcommand!("ref", imagref, version)) - .subcommand(build_subcommand!("store", imagstore, version)) - .subcommand(build_subcommand!("tag", imagtag, version)) - .subcommand(build_subcommand!("view", imagview, version)) - .subcommand(build_subcommand!("bookmark", imagbookmark, version)) - .subcommand(build_subcommand!("contact", imagcontact, version)) - .subcommand(build_subcommand!("diary", imagdiary, version)) - .subcommand(build_subcommand!("habit", imaghabit, version)) - .subcommand(build_subcommand!("log", imaglog, version)) - .subcommand(build_subcommand!("mail", imagmail, version)) - .subcommand(build_subcommand!("notes", imagnotes, version)) - .subcommand(build_subcommand!("timetrack", imagtimetrack, version)) - .subcommand(build_subcommand!("todo", imagtodo, version)); + .subcommand(build_subcommand!("annotate" , imagannotate , version)) + .subcommand(build_subcommand!("bookmark" , imagbookmark , version)) + .subcommand(build_subcommand!("category" , imagcategory , version)) + .subcommand(build_subcommand!("contact" , imagcontact , version)) + .subcommand(build_subcommand!("diagnostics" , imagdiagnostics , version)) + .subcommand(build_subcommand!("diary" , imagdiary , version)) + .subcommand(build_subcommand!("edit" , imagedit , version)) + .subcommand(build_subcommand!("git" , imaggit , version)) + .subcommand(build_subcommand!("gps" , imaggps , version)) + .subcommand(build_subcommand!("grep" , imaggrep , version)) + .subcommand(build_subcommand!("habit" , imaghabit , version)) + .subcommand(build_subcommand!("ids" , imagids , version)) + .subcommand(build_subcommand!("init" , imaginit , version)) + .subcommand(build_subcommand!("link" , imaglink , version)) + .subcommand(build_subcommand!("log" , imaglog , version)) + .subcommand(build_subcommand!("mail" , imagmail , version)) + .subcommand(build_subcommand!("mv" , imagmv , version)) + .subcommand(build_subcommand!("notes" , imagnotes , version)) + .subcommand(build_subcommand!("ref" , imagref , version)) + .subcommand(build_subcommand!("store" , imagstore , version)) + .subcommand(build_subcommand!("tag" , imagtag , version)) + .subcommand(build_subcommand!("timetrack" , imagtimetrack , version)) + .subcommand(build_subcommand!("todo" , imagtodo , version)) + .subcommand(build_subcommand!("view" , imagview , version)) + .subcommand(build_subcommand!("wiki" , imagwiki , version)); // Actually generates the completion files app.gen_completions("imag", Shell::Bash, "../../../target/"); @@ -139,3 +143,4 @@ fn main() { toplevelbuildscript::build(); } +