Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package git-delta for openSUSE:Factory checked in at 2021-02-23 20:20:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/git-delta (Old) and /work/SRC/openSUSE:Factory/.git-delta.new.2378 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "git-delta" Tue Feb 23 20:20:58 2021 rev:4 rq:874336 version:0.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/git-delta/git-delta.changes 2021-02-17 18:13:14.962024510 +0100 +++ /work/SRC/openSUSE:Factory/.git-delta.new.2378/git-delta.changes 2021-02-23 20:22:39.435775183 +0100 @@ -1,0 +2,19 @@ +Thu Feb 18 20:52:58 UTC 2021 - Gordon Schulz <[email protected]> + +- Update to version 0.6.0 + * This release brings a new and more convenient way to change delta + options in a one-off git command: using git -c. Here's an example: + + git -c delta.line-numbers=false -c delta.max-line-distance=0.8 show + + One note: while quotes around color hex codes are required in + gitconfig, they can be omitted in the git -c context + + git -c delta.plus-style='syntax "#aa0000"' + git -c delta.plus-style='syntax #aa0000' + * Hunk header misaligned in some cases + * Delta does not respect git -c + * Can't disable line numbering from command line + * Support for Apple Silicon/ARM64 + +------------------------------------------------------------------- Old: ---- git-delta-0.5.1.tar.gz New: ---- git-delta-0.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ git-delta.spec ++++++ --- /var/tmp/diff_new_pack.J75Pkj/_old 2021-02-23 20:22:40.531776152 +0100 +++ /var/tmp/diff_new_pack.J75Pkj/_new 2021-02-23 20:22:40.535776156 +0100 @@ -17,7 +17,7 @@ Name: git-delta -Version: 0.5.1 +Version: 0.6.0 Release: 0 Summary: A syntax-highlighter for git and diff output License: MIT ++++++ git-delta-0.5.1.tar.gz -> git-delta-0.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/Cargo.lock new/delta-0.6.0/Cargo.lock --- old/delta-0.5.1/Cargo.lock 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/Cargo.lock 2021-02-05 15:13:37.000000000 +0100 @@ -258,7 +258,7 @@ [[package]] name = "git-delta" -version = "0.5.1" +version = "0.6.0" dependencies = [ "ansi_colours", "ansi_term 0.12.1", @@ -283,9 +283,9 @@ [[package]] name = "git2" -version = "0.13.15" +version = "0.13.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f267c9da8a4de3c615b59e23606c75f164f84896e97f4dd6c15a4294de4359" +checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986" dependencies = [ "bitflags", "libc", @@ -386,9 +386,9 @@ [[package]] name = "libgit2-sys" -version = "0.12.17+1.1.0" +version = "0.12.18+1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ebdf65ca745126df8824688637aa0535a88900b83362d8ca63893bcf4e8841" +checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885" dependencies = [ "cc", "libc", @@ -581,9 +581,9 @@ [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -593,9 +593,9 @@ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "ryu" @@ -832,9 +832,9 @@ [[package]] name = "vte" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7745610024d50ab1ebfa41f8f8ee361c567f7ab51032f93cc1cc4cbf0c547a" +checksum = "2df25fed2855d2fbcbdf1016c69a6ac070fa1aabc8b5d7aedaab8703dce0d2d6" dependencies = [ "arrayvec", "utf8parse", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/Cargo.toml new/delta-0.6.0/Cargo.toml --- old/delta-0.5.1/Cargo.toml 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/Cargo.toml 2021-02-05 15:13:37.000000000 +0100 @@ -8,7 +8,7 @@ homepage = "https://github.com/dandavison/delta" license = "MIT" repository = "https://github.com/dandavison/delta" -version = "0.5.1" +version = "0.6.0" [[bin]] name = "delta" @@ -25,15 +25,15 @@ dirs-next = "2.0.0" itertools = "0.10.0" lazy_static = "1.4" -regex = "1.4.2" +regex = "1.4.3" shell-words = "1.0.0" structopt = "0.3.21" unicode-segmentation = "1.7.1" unicode-width = "0.1.8" -vte = "0.9.0" +vte = "0.10.0" [dependencies.git2] -version = "0.13.15" +version = "0.13.17" default-features = false features = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/HomeBrewFormula/git-delta.rb new/delta-0.6.0/HomeBrewFormula/git-delta.rb --- old/delta-0.5.1/HomeBrewFormula/git-delta.rb 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/HomeBrewFormula/git-delta.rb 2021-02-05 15:13:37.000000000 +0100 @@ -1,5 +1,5 @@ class GitDelta < Formula - version "0.5.0" + version "0.5.1" desc "A viewer for git and diff output" homepage "https://github.com/dandavison/delta" @@ -7,10 +7,10 @@ if OS.mac? url "https://github.com/dandavison/delta/releases/download/#{version}/delta-#{version}-x86_64-apple-darwin.tar.gz" - sha256 "ee25dd91822d77c9dcfac4ee089c48fec816a36c7080c28fd9b5f376a6ce4582" + sha256 "3f1819e8c3a728d403ff9091b105d20ff55f01177e704dad2db50829ec00a761" elsif OS.linux? url "https://github.com/dandavison/delta/releases/download/#{version}/delta-#{version}-x86_64-unknown-linux-musl.tar.gz" - sha256 "5fd66697390c77546accc88d35e65a46e377b463fc48dc933cb6b3ae6216f7db" + sha256 "ca642ea53894413640b9272236fa54e77b9a7aff0cb6b5ea2e41e4e68cc8f832" end conflicts_with "delta" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/README.md new/delta-0.6.0/README.md --- old/delta-0.5.1/README.md 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/README.md 2021-02-05 15:13:37.000000000 +0100 @@ -73,6 +73,8 @@ </sub> +Use `delta --help` to see all the available options. + To quickly change delta configuration on-the-fly, use the `git config --global` command. For example ```bash @@ -197,7 +199,7 @@ ## Installation -You can download an executable for your system: [Linux](https://github.com/dandavison/delta/releases/download/0.5.0/delta-0.5.0-x86_64-unknown-linux-gnu.tar.gz) | [MacOS (recent versions)](https://github.com/dandavison/delta/releases/download/0.5.0/delta-0.5.0-x86_64-apple-darwin.tar.gz) | [Windows](https://github.com/dandavison/delta/releases/download/0.5.0/delta-0.5.0-x86_64-pc-windows-msvc.zip) | [All](https://github.com/dandavison/delta/releases) +You can download an executable for your system: [Linux](https://github.com/dandavison/delta/releases/download/0.5.1/delta-0.5.1-x86_64-unknown-linux-gnu.tar.gz) | [MacOS (recent versions)](https://github.com/dandavison/delta/releases/download/0.5.1/delta-0.5.1-x86_64-apple-darwin.tar.gz) | [Windows](https://github.com/dandavison/delta/releases/download/0.5.1/delta-0.5.1-x86_64-pc-windows-msvc.zip) | [All](https://github.com/dandavison/delta/releases) Alternatively, delta is available in the following package managers: @@ -282,7 +284,7 @@ #### Git config files -Set delta to be git's pager in your `.gitconfig`. Delta has many options to alter colors and other details of the output. An example is +Set delta to be git's pager in your `.gitconfig`. Delta has many options to alter colors and other details of the output; `delta --help` shows them all. An example is ```gitconfig [core] pager = delta @@ -483,8 +485,11 @@ ### Mouse scrolling -If mouse scrolling isn't working correctly, try setting your `BAT_PAGER` environment variable to (at least) `less -R` . -See [issue #58](https://github.com/dandavison/delta/issues/58) and [bat README / "Using a different pager"](https://github.com/sharkdp/bat#using-a-different-pager). +If mouse scrolling isn't working correctly, ensure that you have the most recent version of `less`. +* For Windows you can download from https://github.com/jftuga/less-Windows/releases/latest +* For Mac you can install `brew install less; brew link less` + +Alternatively try setting your `DELTA_PAGER` environment variable to (at least) `less -R`. See [issue #58](https://github.com/dandavison/delta/issues/58). See also [bat README / "Using a different pager"](https://github.com/sharkdp/bat#using-a-different-pager), since the `DELTA_PAGER` environment variable functions very similarly for delta. ### Using Delta with Magit @@ -600,7 +605,7 @@ ## Full --help output ``` -delta 0.5.0 +delta 0.5.1 A viewer for git and diff output USAGE: @@ -700,9 +705,16 @@ --hunk-header-style <hunk-header-style> Style (foreground, background, attributes) for the hunk-header. See STYLES section. Special attributes 'file' and 'line-number' can be used to include the file path, and number of first hunk line, in the hunk - header. If included in the hunk header, 'file' and 'line-number' are styled according to 'file-style' and - 'hunk-header-decoration-style' respectively. The style 'omit' can be used to remove the hunk header section - from the output [default: line-number syntax] + header. The style 'omit' can be used to remove the hunk header section from the output [default: line- + number syntax] + --hunk-header-file-style <hunk-header-file-style> + Style (foreground, background, attributes) for the file path part of the hunk-header. See STYLES section. + The file path will only be displayed if hunk-header-style contains the 'file' special attribute [default: + blue] + --hunk-header-line-number-style <hunk-header-line-number-style> + Style (foreground, background, attributes) for the line number part of the hunk-header. See STYLES section. + The line number will only be displayed if hunk-header-style contains the 'line-number' special attribute + [default: blue] --hunk-header-decoration-style <hunk-header-decoration-style> Style (foreground, background, attributes) for the hunk-header decoration. See STYLES section. The style string should contain one of the special attributes 'box', 'ul' (underline), 'ol' (overline), or the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/ansi/iterator.rs new/delta-0.6.0/src/ansi/iterator.rs --- old/delta-0.5.1/src/ansi/iterator.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/ansi/iterator.rs 2021-02-05 15:13:37.000000000 +0100 @@ -261,7 +261,7 @@ } // Based on https://github.com/alacritty/alacritty/blob/57c4ac9145a20fb1ae9a21102503458d3da06c7b/alacritty_terminal/src/ansi.rs#L1258 -fn parse_sgr_color(params: &mut dyn Iterator<Item = i64>) -> Option<ansi_term::Color> { +fn parse_sgr_color(params: &mut dyn Iterator<Item = u16>) -> Option<ansi_term::Color> { match params.next() { Some(2) => { let r = u8::try_from(params.next()?).ok()?; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/cli.rs new/delta-0.6.0/src/cli.rs --- old/delta-0.5.1/src/cli.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/cli.rs 2021-02-05 15:13:37.000000000 +0100 @@ -11,8 +11,7 @@ use crate::bat_utils::assets::HighlightingAssets; use crate::bat_utils::output::PagingMode; -use crate::git_config::GitConfig; -use crate::git_config_entry::GitConfigEntry; +use crate::git_config::{GitConfig, GitConfigEntry}; use crate::options; #[derive(StructOpt, Clone, Default)] @@ -366,10 +365,8 @@ #[structopt(long = "hunk-header-style", default_value = "line-number syntax")] /// Style (foreground, background, attributes) for the hunk-header. See STYLES section. Special /// attributes 'file' and 'line-number' can be used to include the file path, and number of - /// first hunk line, in the hunk header. If included in the hunk header, 'file' and - /// 'line-number' are styled according to 'file-style' and 'hunk-header-decoration-style' - /// respectively. The style 'omit' can be used to remove the hunk header section from the - /// output. + /// first hunk line, in the hunk header. The style 'omit' can be used to remove the hunk header + /// section from the output. pub hunk_header_style: String, #[structopt(long = "hunk-header-file-style", default_value = "blue")] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/config.rs new/delta-0.6.0/src/config.rs --- old/delta-0.5.1/src/config.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/config.rs 2021-02-05 15:13:37.000000000 +0100 @@ -14,7 +14,7 @@ use crate::delta::State; use crate::env; use crate::features::side_by_side; -use crate::git_config_entry::GitConfigEntry; +use crate::git_config::GitConfigEntry; use crate::style::{self, Style}; pub struct Config { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/features/hyperlinks.rs new/delta-0.6.0/src/features/hyperlinks.rs --- old/delta-0.5.1/src/features/hyperlinks.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/features/hyperlinks.rs 2021-02-05 15:13:37.000000000 +0100 @@ -5,7 +5,7 @@ use crate::config::Config; use crate::features::OptionValueFunction; -use crate::git_config_entry::{GitConfigEntry, GitRemoteRepo}; +use crate::git_config::{GitConfigEntry, GitRemoteRepo}; pub fn make_feature() -> Vec<(String, OptionValueFunction)> { builtin_feature!([ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/git_config/git_config_entry.rs new/delta-0.6.0/src/git_config/git_config_entry.rs --- old/delta-0.5.1/src/git_config/git_config_entry.rs 1970-01-01 01:00:00.000000000 +0100 +++ new/delta-0.6.0/src/git_config/git_config_entry.rs 2021-02-05 15:13:37.000000000 +0100 @@ -0,0 +1,39 @@ +use std::path::PathBuf; +use std::result::Result; +use std::str::FromStr; + +use lazy_static::lazy_static; +use regex::Regex; + +use crate::errors::*; + +#[derive(Clone, Debug)] +pub enum GitConfigEntry { + Style(String), + GitRemote(GitRemoteRepo), + Path(PathBuf), +} + +#[derive(Clone, Debug)] +pub enum GitRemoteRepo { + GitHubRepo(String), +} + +lazy_static! { + static ref GITHUB_REMOTE_URL: Regex = Regex::new(r"github\.com[:/]([^/]+)/(.+)\.git").unwrap(); +} + +impl FromStr for GitRemoteRepo { + type Err = Error; + fn from_str(s: &str) -> Result<Self, Self::Err> { + if let Some(caps) = GITHUB_REMOTE_URL.captures(s) { + Ok(Self::GitHubRepo(format!( + "{user}/{repo}", + user = caps.get(1).unwrap().as_str(), + repo = caps.get(2).unwrap().as_str() + ))) + } else { + Err("Not a GitHub repo.".into()) + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/git_config/mod.rs new/delta-0.6.0/src/git_config/mod.rs --- old/delta-0.5.1/src/git_config/mod.rs 1970-01-01 01:00:00.000000000 +0100 +++ new/delta-0.6.0/src/git_config/mod.rs 2021-02-05 15:13:37.000000000 +0100 @@ -0,0 +1,198 @@ +mod git_config_entry; + +pub use git_config_entry::{GitConfigEntry, GitRemoteRepo}; + +use regex::Regex; +use std::collections::HashMap; +use std::env; +#[cfg(test)] +use std::path::Path; +use std::process; + +use lazy_static::lazy_static; + +pub struct GitConfig { + config: git2::Config, + config_from_env_var: HashMap<String, String>, + pub enabled: bool, + pub repo: Option<git2::Repository>, +} + +impl GitConfig { + pub fn try_create() -> Option<Self> { + let repo = match std::env::current_dir() { + Ok(dir) => git2::Repository::discover(dir).ok(), + _ => None, + }; + let config = match &repo { + Some(repo) => repo.config().ok(), + None => git2::Config::open_default().ok(), + }; + match config { + Some(mut config) => { + let config = config.snapshot().unwrap_or_else(|err| { + eprintln!("Failed to read git config: {}", err); + process::exit(1) + }); + Some(Self { + config, + config_from_env_var: parse_config_from_env_var(), + repo, + enabled: true, + }) + } + None => None, + } + } + + #[cfg(test)] + pub fn from_path(path: &Path, honor_env_var: bool) -> Self { + Self { + config: git2::Config::open(path).unwrap(), + config_from_env_var: if honor_env_var { + parse_config_from_env_var() + } else { + HashMap::new() + }, + repo: None, + enabled: true, + } + } + + pub fn get<T>(&self, key: &str) -> Option<T> + where + T: GitConfigGet, + { + if self.enabled { + T::git_config_get(key, self) + } else { + None + } + } +} + +fn parse_config_from_env_var() -> HashMap<String, String> { + if let Ok(s) = env::var("GIT_CONFIG_PARAMETERS") { + parse_config_from_env_var_value(&s) + } else { + HashMap::new() + } +} + +lazy_static! { + static ref GIT_CONFIG_PARAMETERS_REGEX: Regex = + Regex::new(r"'(delta\.[a-z-]+)=([^']+)'").unwrap(); +} + +fn parse_config_from_env_var_value(s: &str) -> HashMap<String, String> { + GIT_CONFIG_PARAMETERS_REGEX + .captures_iter(s) + .map(|captures| (captures[1].to_string(), captures[2].to_string())) + .collect() +} + +pub trait GitConfigGet { + fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> + where + Self: Sized; +} + +impl GitConfigGet for String { + fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { + match git_config.config_from_env_var.get(key) { + Some(val) => Some(val.to_string()), + None => git_config.config.get_string(key).ok(), + } + } +} + +impl GitConfigGet for Option<String> { + fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { + match git_config.config_from_env_var.get(key) { + Some(val) => Some(Some(val.to_string())), + None => match git_config.config.get_string(key) { + Ok(val) => Some(Some(val)), + _ => None, + }, + } + } +} + +impl GitConfigGet for bool { + fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { + match git_config.config_from_env_var.get(key).map(|s| s.as_str()) { + Some("true") => Some(true), + Some("false") => Some(false), + _ => git_config.config.get_bool(key).ok(), + } + } +} + +impl GitConfigGet for usize { + fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { + if let Some(s) = git_config.config_from_env_var.get(key) { + if let Ok(n) = s.parse::<usize>() { + return Some(n); + } + } + match git_config.config.get_i64(key) { + Ok(value) => Some(value as usize), + _ => None, + } + } +} + +impl GitConfigGet for f64 { + fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { + if let Some(s) = git_config.config_from_env_var.get(key) { + if let Ok(n) = s.parse::<f64>() { + return Some(n); + } + } + match git_config.config.get_string(key) { + Ok(value) => value.parse::<f64>().ok(), + _ => None, + } + } +} + +#[cfg(test)] +mod tests { + + use super::parse_config_from_env_var_value; + + #[test] + fn test_parse_config_from_env_var_value() { + // To generate test cases, use git -c ... with + // [core] + // pager = env | grep GIT_CONFIG_PARAMETERS + + let config = parse_config_from_env_var_value("'user.name=xxx'"); + assert!(config.is_empty()); + + let config = parse_config_from_env_var_value("'delta.plus-style=green'"); + assert_eq!(config["delta.plus-style"], "green"); + + let config = parse_config_from_env_var_value( + r##"'user.name=xxx' 'delta.hunk-header-line-number-style=red "#067a00"'"##, + ); + assert_eq!( + config["delta.hunk-header-line-number-style"], + r##"red "#067a00""## + ); + + let config = + parse_config_from_env_var_value(r##"'user.name=xxx' 'delta.side-by-side=false'"##); + assert_eq!(config["delta.side-by-side"], "false"); + + let config = parse_config_from_env_var_value( + r##"'delta.plus-style=green' 'delta.side-by-side=false' 'delta.hunk-header-line-number-style=red "#067a00"'"##, + ); + assert_eq!(config["delta.plus-style"], "green"); + assert_eq!(config["delta.side-by-side"], "false"); + assert_eq!( + config["delta.hunk-header-line-number-style"], + r##"red "#067a00""## + ); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/git_config.rs new/delta-0.6.0/src/git_config.rs --- old/delta-0.5.1/src/git_config.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/git_config.rs 1970-01-01 01:00:00.000000000 +0100 @@ -1,101 +0,0 @@ -#[cfg(test)] -use std::path::Path; -use std::process; - -pub struct GitConfig { - config: git2::Config, - pub enabled: bool, - pub repo: Option<git2::Repository>, -} - -impl GitConfig { - pub fn try_create() -> Option<Self> { - let repo = match std::env::current_dir() { - Ok(dir) => git2::Repository::discover(dir).ok(), - _ => None, - }; - let config = match &repo { - Some(repo) => repo.config().ok(), - None => git2::Config::open_default().ok(), - }; - match config { - Some(mut config) => { - let config = config.snapshot().unwrap_or_else(|err| { - eprintln!("Failed to read git config: {}", err); - process::exit(1) - }); - Some(Self { - config, - repo, - enabled: true, - }) - } - None => None, - } - } - - #[cfg(test)] - pub fn from_path(path: &Path) -> Self { - Self { - config: git2::Config::open(path).unwrap(), - repo: None, - enabled: true, - } - } - - pub fn get<T>(&self, key: &str) -> Option<T> - where - T: GitConfigGet, - { - if self.enabled { - T::git_config_get(key, self) - } else { - None - } - } -} - -pub trait GitConfigGet { - fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> - where - Self: Sized; -} - -impl GitConfigGet for String { - fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { - git_config.config.get_string(key).ok() - } -} - -impl GitConfigGet for Option<String> { - fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { - match git_config.config.get_string(key) { - Ok(value) => Some(Some(value)), - _ => None, - } - } -} - -impl GitConfigGet for bool { - fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { - git_config.config.get_bool(key).ok() - } -} - -impl GitConfigGet for usize { - fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { - match git_config.config.get_i64(key) { - Ok(value) => Some(value as usize), - _ => None, - } - } -} - -impl GitConfigGet for f64 { - fn git_config_get(key: &str, git_config: &GitConfig) -> Option<Self> { - match git_config.config.get_string(key) { - Ok(value) => value.parse::<f64>().ok(), - _ => None, - } - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/git_config_entry.rs new/delta-0.6.0/src/git_config_entry.rs --- old/delta-0.5.1/src/git_config_entry.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/git_config_entry.rs 1970-01-01 01:00:00.000000000 +0100 @@ -1,39 +0,0 @@ -use std::path::PathBuf; -use std::result::Result; -use std::str::FromStr; - -use lazy_static::lazy_static; -use regex::Regex; - -use crate::errors::*; - -#[derive(Clone, Debug)] -pub enum GitConfigEntry { - Style(String), - GitRemote(GitRemoteRepo), - Path(PathBuf), -} - -#[derive(Clone, Debug)] -pub enum GitRemoteRepo { - GitHubRepo(String), -} - -lazy_static! { - static ref GITHUB_REMOTE_URL: Regex = Regex::new(r"github\.com[:/]([^/]+)/(.+)\.git").unwrap(); -} - -impl FromStr for GitRemoteRepo { - type Err = Error; - fn from_str(s: &str) -> Result<Self, Self::Err> { - if let Some(caps) = GITHUB_REMOTE_URL.captures(s) { - Ok(Self::GitHubRepo(format!( - "{user}/{repo}", - user = caps.get(1).unwrap().as_str(), - repo = caps.get(2).unwrap().as_str() - ))) - } else { - Err("Not a GitHub repo.".into()) - } - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/hunk_header.rs new/delta-0.6.0/src/hunk_header.rs --- old/delta-0.5.1/src/hunk_header.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/hunk_header.rs 2021-02-05 15:13:37.000000000 +0100 @@ -21,6 +21,8 @@ use std::fmt::Write as FmtWrite; +use unicode_segmentation::UnicodeSegmentation; + use crate::config::Config; use crate::delta; use crate::draw; @@ -133,7 +135,10 @@ let _ = write!(&mut painter.output_buffer, "{}: ", file_with_line_number); } if !line.is_empty() { - let lines = vec![(line, delta::State::HunkHeader)]; + let lines = vec![( + painter.expand_tabs(line.graphemes(true)), + delta::State::HunkHeader, + )]; let syntax_style_sections = Painter::get_syntax_style_sections_for_lines( &lines, &delta::State::HunkHeader, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/main.rs new/delta-0.6.0/src/main.rs --- old/delta-0.5.1/src/main.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/main.rs 2021-02-05 15:13:37.000000000 +0100 @@ -17,7 +17,6 @@ mod features; mod format; mod git_config; -mod git_config_entry; mod hunk_header; mod options; mod paint; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/options/get.rs new/delta-0.6.0/src/options/get.rs --- old/delta-0.5.1/src/options/get.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/options/get.rs 2021-02-05 15:13:37.000000000 +0100 @@ -109,3 +109,170 @@ impl GetOptionValue for bool {} impl GetOptionValue for f64 {} impl GetOptionValue for usize {} + +#[cfg(test)] +pub mod tests { + use std::env; + use std::fs::remove_file; + + use crate::tests::integration_test_utils::integration_test_utils; + + // TODO: the followig tests are collapsed into one since they all set the same env var and thus + // could affect each other if allowed to run concurrently. + + #[test] + fn test_env_var_overrides_git_config() { + // ---------------------------------------------------------------------------------------- + // simple string + let git_config_contents = b" +[delta] + plus-style = blue +"; + let git_config_path = "delta__test_simple_string_env_var_overrides_git_config.gitconfig"; + + let opt = integration_test_utils::make_options_from_args_and_git_config( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.plus_style, "blue"); + + env::set_var("GIT_CONFIG_PARAMETERS", "'delta.plus-style=green'"); + let opt = integration_test_utils::make_options_from_args_and_git_config_honoring_env_var( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.plus_style, "green"); + + remove_file(git_config_path).unwrap(); + + // ---------------------------------------------------------------------------------------- + // complex string + let git_config_contents = br##" +[delta] + minus-style = red bold ul "#ffeeee" +"##; + let git_config_path = "delta__test_complex_string_env_var_overrides_git_config.gitconfig"; + + let opt = integration_test_utils::make_options_from_args_and_git_config( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.minus_style, r##"red bold ul #ffeeee"##); + + env::set_var( + "GIT_CONFIG_PARAMETERS", + r##"'delta.minus-style=magenta italic ol "#aabbcc"'"##, + ); + let opt = integration_test_utils::make_options_from_args_and_git_config_honoring_env_var( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.minus_style, r##"magenta italic ol "#aabbcc""##,); + + remove_file(git_config_path).unwrap(); + + // ---------------------------------------------------------------------------------------- + // option string + let git_config_contents = b" +[delta] + plus-style = blue +"; + let git_config_path = "delta__test_option_string_env_var_overrides_git_config.gitconfig"; + + let opt = integration_test_utils::make_options_from_args_and_git_config( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.plus_style, "blue"); + + env::set_var("GIT_CONFIG_PARAMETERS", "'delta.plus-style=green'"); + let opt = integration_test_utils::make_options_from_args_and_git_config_honoring_env_var( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.plus_style, "green"); + + remove_file(git_config_path).unwrap(); + + // ---------------------------------------------------------------------------------------- + // bool + let git_config_contents = b" +[delta] + side-by-side = true +"; + let git_config_path = "delta__test_bool_env_var_overrides_git_config.gitconfig"; + + let opt = integration_test_utils::make_options_from_args_and_git_config( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.side_by_side, true); + + env::set_var("GIT_CONFIG_PARAMETERS", "'delta.side-by-side=false'"); + let opt = integration_test_utils::make_options_from_args_and_git_config_honoring_env_var( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.side_by_side, false); + + remove_file(git_config_path).unwrap(); + + // ---------------------------------------------------------------------------------------- + // int + let git_config_contents = b" +[delta] + max-line-length = 1 +"; + let git_config_path = "delta__test_int_env_var_overrides_git_config.gitconfig"; + + let opt = integration_test_utils::make_options_from_args_and_git_config( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.max_line_length, 1); + + env::set_var("GIT_CONFIG_PARAMETERS", "'delta.max-line-length=2'"); + let opt = integration_test_utils::make_options_from_args_and_git_config_honoring_env_var( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.max_line_length, 2); + + remove_file(git_config_path).unwrap(); + + // ---------------------------------------------------------------------------------------- + // float + let git_config_contents = b" +[delta] + max-line-distance = 0.6 +"; + let git_config_path = "delta__test_float_env_var_overrides_git_config.gitconfig"; + + let opt = integration_test_utils::make_options_from_args_and_git_config_honoring_env_var( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.max_line_distance, 0.6); + + env::set_var("GIT_CONFIG_PARAMETERS", "'delta.max-line-distance=0.7'"); + let opt = integration_test_utils::make_options_from_args_and_git_config_honoring_env_var( + &[], + Some(git_config_contents), + Some(git_config_path), + ); + assert_eq!(opt.max_line_distance, 0.7); + + remove_file(git_config_path).unwrap(); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/options/rewrite.rs new/delta-0.6.0/src/options/rewrite.rs --- old/delta-0.5.1/src/options/rewrite.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/options/rewrite.rs 2021-02-05 15:13:37.000000000 +0100 @@ -109,7 +109,7 @@ } match opt.deprecated_hunk_style.as_deref().map(str::to_lowercase) { Some(attr) if attr == "plain" => opt.hunk_header_decoration_style = "".to_string(), - Some(attr) if attr == "" => {} + Some(attr) if attr.is_empty() => {} Some(attr) => opt.hunk_header_decoration_style = attr, None => {} } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/options/set.rs new/delta-0.6.0/src/options/set.rs --- old/delta-0.5.1/src/options/set.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/options/set.rs 2021-02-05 15:13:37.000000000 +0100 @@ -13,8 +13,7 @@ use crate::env; use crate::errors::*; use crate::features; -use crate::git_config; -use crate::git_config_entry::{self, GitConfigEntry}; +use crate::git_config::{GitConfig, GitConfigEntry, GitRemoteRepo}; use crate::options::option_value::{OptionValue, ProvenancedOptionValue}; use crate::options::theme; @@ -64,7 +63,7 @@ pub fn set_options( opt: &mut cli::Opt, - git_config: &mut Option<git_config::GitConfig>, + git_config: &mut Option<GitConfig>, arg_matches: &clap::ArgMatches, assets: HighlightingAssets, ) { @@ -204,7 +203,7 @@ #[allow(non_snake_case)] fn set__light__dark__syntax_theme__options( opt: &mut cli::Opt, - git_config: &mut Option<git_config::GitConfig>, + git_config: &mut Option<GitConfig>, arg_matches: &clap::ArgMatches, option_names: &HashMap<&str, &str>, ) { @@ -291,7 +290,7 @@ fn gather_features( opt: &cli::Opt, builtin_features: &HashMap<String, features::BuiltinFeature>, - git_config: &Option<git_config::GitConfig>, + git_config: &Option<GitConfig>, ) -> Vec<String> { let mut features = VecDeque::new(); @@ -372,7 +371,7 @@ features: &mut VecDeque<String>, builtin_features: &HashMap<String, features::BuiltinFeature>, opt: &cli::Opt, - git_config: &git_config::GitConfig, + git_config: &GitConfig, ) { if builtin_features.contains_key(feature) { gather_builtin_features_recursively(feature, features, builtin_features, opt); @@ -408,7 +407,7 @@ features: &mut VecDeque<String>, builtin_features: &HashMap<String, features::BuiltinFeature>, opt: &cli::Opt, - git_config: &git_config::GitConfig, + git_config: &GitConfig, ) { for child_feature in builtin_features.keys() { if let Some(value) = @@ -510,7 +509,7 @@ fn set_widths( opt: &mut cli::Opt, - git_config: &mut Option<git_config::GitConfig>, + git_config: &mut Option<GitConfig>, arg_matches: &clap::ArgMatches, option_names: &HashMap<&str, &str>, ) { @@ -571,7 +570,7 @@ .unwrap_or(false) } -fn set_git_config_entries(opt: &mut cli::Opt, git_config: &mut git_config::GitConfig) { +fn set_git_config_entries(opt: &mut cli::Opt, git_config: &mut GitConfig) { // Styles for key in &["color.diff.old", "color.diff.new"] { if let Some(style_string) = git_config.get::<String>(key) { @@ -583,7 +582,7 @@ // Strings for key in &["remote.origin.url"] { if let Some(string) = git_config.get::<String>(key) { - if let Ok(repo) = git_config_entry::GitRemoteRepo::from_str(&string) { + if let Ok(repo) = GitRemoteRepo::from_str(&string) { opt.git_config_entries .insert(key.to_string(), GitConfigEntry::GitRemote(repo)); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/style.rs new/delta-0.6.0/src/style.rs --- old/delta-0.5.1/src/style.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/style.rs 2021-02-05 15:13:37.000000000 +0100 @@ -166,17 +166,17 @@ } fn ansi_term_16_color_equality(a: ansi_term::Color, b: ansi_term::Color) -> bool { - match (a, b) { - (ansi_term::Color::Fixed(0), ansi_term::Color::Black) => true, - (ansi_term::Color::Fixed(1), ansi_term::Color::Red) => true, - (ansi_term::Color::Fixed(2), ansi_term::Color::Green) => true, - (ansi_term::Color::Fixed(3), ansi_term::Color::Yellow) => true, - (ansi_term::Color::Fixed(4), ansi_term::Color::Blue) => true, - (ansi_term::Color::Fixed(5), ansi_term::Color::Purple) => true, - (ansi_term::Color::Fixed(6), ansi_term::Color::Cyan) => true, - (ansi_term::Color::Fixed(7), ansi_term::Color::White) => true, - _ => false, - } + matches!( + (a, b), + (ansi_term::Color::Fixed(0), ansi_term::Color::Black) + | (ansi_term::Color::Fixed(1), ansi_term::Color::Red) + | (ansi_term::Color::Fixed(2), ansi_term::Color::Green) + | (ansi_term::Color::Fixed(3), ansi_term::Color::Yellow) + | (ansi_term::Color::Fixed(4), ansi_term::Color::Blue) + | (ansi_term::Color::Fixed(5), ansi_term::Color::Purple) + | (ansi_term::Color::Fixed(6), ansi_term::Color::Cyan) + | (ansi_term::Color::Fixed(7), ansi_term::Color::White) + ) } lazy_static! { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/src/tests/integration_test_utils.rs new/delta-0.6.0/src/tests/integration_test_utils.rs --- old/delta-0.5.1/src/tests/integration_test_utils.rs 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/src/tests/integration_test_utils.rs 2021-02-05 15:13:37.000000000 +0100 @@ -18,11 +18,28 @@ git_config_contents: Option<&[u8]>, git_config_path: Option<&str>, ) -> cli::Opt { + _make_options_from_args_and_git_config(args, git_config_contents, git_config_path, false) + } + + pub fn make_options_from_args_and_git_config_honoring_env_var( + args: &[&str], + git_config_contents: Option<&[u8]>, + git_config_path: Option<&str>, + ) -> cli::Opt { + _make_options_from_args_and_git_config(args, git_config_contents, git_config_path, true) + } + + fn _make_options_from_args_and_git_config( + args: &[&str], + git_config_contents: Option<&[u8]>, + git_config_path: Option<&str>, + honor_env_var: bool, + ) -> cli::Opt { let mut args: Vec<&str> = itertools::chain(&["/dev/null", "/dev/null"], args) .map(|s| *s) .collect(); let mut git_config = match (git_config_contents, git_config_path) { - (Some(contents), Some(path)) => Some(make_git_config(contents, path)), + (Some(contents), Some(path)) => Some(make_git_config(contents, path, honor_env_var)), _ => { args.push("--no-gitconfig"); None @@ -52,11 +69,11 @@ config::Config::from(make_options_from_args(args)) } - fn make_git_config(contents: &[u8], path: &str) -> GitConfig { + fn make_git_config(contents: &[u8], path: &str, honor_env_var: bool) -> GitConfig { let path = Path::new(path); let mut file = File::create(path).unwrap(); file.write_all(contents).unwrap(); - GitConfig::from_path(&path) + GitConfig::from_path(&path, honor_env_var) } pub fn get_line_of_code_from_delta( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/delta-0.5.1/themes.gitconfig new/delta-0.6.0/themes.gitconfig --- old/delta-0.5.1/themes.gitconfig 2021-01-05 00:15:50.000000000 +0100 +++ new/delta-0.6.0/themes.gitconfig 2021-02-05 15:13:37.000000000 +0100 @@ -9,41 +9,64 @@ # # author: https://github.com/me # features = kingfisher # -# Please add your own themes to this file, and open a PR. There is -# only one rule: The name of the theme must be the name of some sort -# of wild organism: mammal, bird, plant, mollusk -- whatever. It can -# be in any language. For example: +# Please add your own themes to this file, and open a PR. Instructions: # -# [delta "kingfisher"] -# hunk-header-style = file line-number syntax -# ... +# 1. The name of the theme must be the name of some sort of wild +# organism: mammal, bird, plant, mollusk -- whatever. It can be in +# any language. +# +# 2. Please include a comment line describing the terminal +# theme/colors that you typically use with this theme. +# +# 3. Feel free to include a comment line indicating who is the author +# of the theme. E.g. a link to your github user page. [delta "woolly-mammoth"] # author: https://github.com/Kr1ss-XD - dark = true - syntax-theme = Vibrant Sunburst - zero-style = syntax - minus-style = syntax "#400000" - minus-emph-style = syntax bold "#780000" - plus-style = syntax "#004000" - plus-emph-style = syntax bold "#007800" - whitespace-error-style = "#280050" reverse - commit-style = 232 bold italic 130 - commit-decoration-style = 232 130 box - file-style = 232 bold 184 - file-decoration-style = "#606018" overline - hunk-header-style = syntax bold italic 237 - hunk-header-decoration-style = none - line-numbers = true - line-numbers-zero-style = "#545474" italic - line-numbers-left-format = "{nm:>1}???" - line-numbers-right-format = "{np:>1}???" - line-numbers-left-style = red - line-numbers-right-style = green - line-numbers-minus-style = red italic black - line-numbers-plus-style = green italic black - file-added-label = [+] - file-copied-label = [C] - file-modified-label = [M] - file-removed-label = [-] - file-renamed-label = [R] + dark = true + syntax-theme = Vibrant Sunburst + zero-style = syntax + minus-style = syntax "#400000" + minus-emph-style = syntax bold "#780000" + plus-style = syntax "#004000" + plus-emph-style = syntax bold "#007800" + whitespace-error-style = "#280050" reverse + commit-style = 232 bold italic 130 + commit-decoration-style = 232 130 box + file-style = 232 bold 184 + file-decoration-style = "#606018" overline + hunk-header-style = syntax bold italic 237 + hunk-header-decoration-style = none + line-numbers = true + line-numbers-zero-style = "#545474" italic + line-numbers-left-format = "{nm:>1}???" + line-numbers-right-format = "{np:>1}???" + line-numbers-left-style = red + line-numbers-right-style = green + line-numbers-minus-style = red italic black + line-numbers-plus-style = green italic black + file-added-label = [+] + file-copied-label = [C] + file-modified-label = [M] + file-removed-label = [-] + file-renamed-label = [R] + +[delta "villsau"] + # author: https://github.com/torarnv + syntax-theme = OneHalfDark + line-numbers = false + hunk-header-style = file line-number syntax + hunk-header-line-number-style = dim magenta + hunk-header-file-style = magenta + hunk-header-decoration-style = omit + file-style = omit + zero-style = dim syntax + minus-style = bold red + minus-non-emph-style = dim red + minus-emph-style = bold red 52 + minus-empty-line-marker-style = normal "#3f0001" + plus-style = bold green + plus-non-emph-style = dim green + plus-emph-style = bold green 22 + plus-empty-line-marker-style = normal "#002800" + whitespace-error-style = reverse red ++++++ vendor.tar.xz ++++++ /work/SRC/openSUSE:Factory/git-delta/vendor.tar.xz /work/SRC/openSUSE:Factory/.git-delta.new.2378/vendor.tar.xz differ: char 26, line 1
