From aaece832c816742b5590d1c014bd0ca8b9f5fd84 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sun, 30 Aug 2020 16:02:15 +0200 Subject: [PATCH 1/6] add more diagnose to CI --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fcf1e67a3..19b98c43a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,10 +70,14 @@ jobs: run: | sudo apt-get -qq install musl-tools - name: Build Debug - run: cargo build --target=x86_64-unknown-linux-musl + run: | + cargo build --target=x86_64-unknown-linux-musl + ./target/x86_64-unknown-linux-musl/debug/gitui --version - name: Build Release run: | cargo build --release --target=x86_64-unknown-linux-musl + ldd ./target/x86_64-unknown-linux-musl/release/gitui + ./target/x86_64-unknown-linux-musl/release/gitui --version rustfmt: name: Rustfmt From a1f47631cef28726226a394228aeabc19172fa62 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sun, 30 Aug 2020 16:07:20 +0200 Subject: [PATCH 2/6] more debug --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19b98c43a1..0c1dae2539 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,8 @@ jobs: - name: Build Debug run: | cargo build --target=x86_64-unknown-linux-musl + ls -lisa ./target/x86_64-unknown-linux-musl/debug + ldd ./target/x86_64-unknown-linux-musl/debug/gitui ./target/x86_64-unknown-linux-musl/debug/gitui --version - name: Build Release run: | From aa2bcfdf02987d115598ff336b7bd0b356c59eb8 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 1 Sep 2020 00:50:07 +0200 Subject: [PATCH 3/6] do not support clipboard copy on linux for now --- .github/workflows/ci.yml | 7 ++----- Cargo.toml | 4 ++-- Makefile | 9 +++++++-- src/components/diff.rs | 12 ++++++++++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c1dae2539..99a7ccdb62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,14 +71,11 @@ jobs: sudo apt-get -qq install musl-tools - name: Build Debug run: | - cargo build --target=x86_64-unknown-linux-musl - ls -lisa ./target/x86_64-unknown-linux-musl/debug - ldd ./target/x86_64-unknown-linux-musl/debug/gitui + make build-linux-musl-debug ./target/x86_64-unknown-linux-musl/debug/gitui --version - name: Build Release run: | - cargo build --release --target=x86_64-unknown-linux-musl - ldd ./target/x86_64-unknown-linux-musl/release/gitui + make build-linux-musl-release ./target/x86_64-unknown-linux-musl/release/gitui --version rustfmt: diff --git a/Cargo.toml b/Cargo.toml index 5878bc49c3..c99add70d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ serde = "1.0" anyhow = "1.0.32" unicode-width = "0.1" textwrap = "0.12" -clipboard = "0.5" +clipboard = { version = "0.5", optional = true } [target.'cfg(not(windows))'.dependencies] pprof = { version = "0.3", features = ["flamegraph"], optional = true } @@ -49,7 +49,7 @@ pprof = { version = "0.3", features = ["flamegraph"], optional = true } maintenance = { status = "actively-developed" } [features] -default=[] +default=["clipboard"] timing=["scopetime/enabled"] [workspace] diff --git a/Makefile b/Makefile index d12a548deb..fa537a24bf 100644 --- a/Makefile +++ b/Makefile @@ -20,12 +20,17 @@ release-win: build-release mkdir -p release tar -C ./target/release/ -czvf ./release/gitui-win.tar.gz ./gitui.exe -release-linux-musl: - cargo build --release --target=x86_64-unknown-linux-musl +release-linux-musl: build-linux-musl-release strip target/x86_64-unknown-linux-musl/release/gitui mkdir -p release tar -C ./target/x86_64-unknown-linux-musl/release/ -czvf ./release/gitui-linux-musl.tar.gz ./gitui +build-linux-musl-debug: + cargo build --target=x86_64-unknown-linux-musl --no-default-features + +build-linux-musl-release: + cargo build --release --target=x86_64-unknown-linux-musl --no-default-features + test: cargo test --workspace diff --git a/src/components/diff.rs b/src/components/diff.rs index 1b8793a765..0419a59f0f 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -8,8 +8,10 @@ use crate::{ strings, try_or_popup, ui::{self, calc_scroll_top, style::SharedTheme}, }; +use anyhow::Result; use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD}; use bytesize::ByteSize; +#[cfg(feature = "clipboard")] use clipboard::{ClipboardContext, ClipboardProvider}; use crossterm::event::Event; use std::{borrow::Cow, cell::Cell, cmp, path::Path}; @@ -21,8 +23,6 @@ use tui::{ Frame, }; -use anyhow::{anyhow, Result}; - #[derive(Default)] struct Current { path: String, @@ -244,7 +244,10 @@ impl DiffComponent { Ok(()) } + #[cfg(feature = "clipboard")] fn copy_string(string: String) -> Result<()> { + use anyhow::anyhow; + let mut ctx: ClipboardContext = ClipboardProvider::new() .map_err(|_| { anyhow!("failed to get access to clipboard") @@ -256,6 +259,11 @@ impl DiffComponent { Ok(()) } + #[cfg(not(feature = "clipboard"))] + fn copy_string(_string: String) -> Result<()> { + Ok(()) + } + fn copy_selection(&self) -> Result<()> { if let Some(diff) = &self.diff { let lines_to_copy: Vec<&str> = diff From b98ed409ae3a7a60249e7441982c0df1d68c4371 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 1 Sep 2020 01:23:52 +0200 Subject: [PATCH 4/6] put into separate module --- src/clipboard.rs | 20 ++++++++++++++++++++ src/components/diff.rs | 26 +++----------------------- src/main.rs | 1 + 3 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 src/clipboard.rs diff --git a/src/clipboard.rs b/src/clipboard.rs new file mode 100644 index 0000000000..a3f4808db5 --- /dev/null +++ b/src/clipboard.rs @@ -0,0 +1,20 @@ +use anyhow::Result; +#[cfg(feature = "clipboard")] +use clipboard::{ClipboardContext, ClipboardProvider}; + +#[cfg(feature = "clipboard")] +pub fn copy_string(string: String) -> Result<()> { + use anyhow::anyhow; + + let mut ctx: ClipboardContext = ClipboardProvider::new() + .map_err(|_| anyhow!("failed to get access to clipboard"))?; + ctx.set_contents(string) + .map_err(|_| anyhow!("failed to set clipboard contents"))?; + + Ok(()) +} + +#[cfg(not(feature = "clipboard"))] +pub fn copy_string(_string: String) -> Result<()> { + Ok(()) +} diff --git a/src/components/diff.rs b/src/components/diff.rs index 0419a59f0f..5038edf6ec 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -11,8 +11,6 @@ use crate::{ use anyhow::Result; use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD}; use bytesize::ByteSize; -#[cfg(feature = "clipboard")] -use clipboard::{ClipboardContext, ClipboardProvider}; use crossterm::event::Event; use std::{borrow::Cow, cell::Cell, cmp, path::Path}; use tui::{ @@ -244,26 +242,6 @@ impl DiffComponent { Ok(()) } - #[cfg(feature = "clipboard")] - fn copy_string(string: String) -> Result<()> { - use anyhow::anyhow; - - let mut ctx: ClipboardContext = ClipboardProvider::new() - .map_err(|_| { - anyhow!("failed to get access to clipboard") - })?; - ctx.set_contents(string).map_err(|_| { - anyhow!("failed to set clipboard contents") - })?; - - Ok(()) - } - - #[cfg(not(feature = "clipboard"))] - fn copy_string(_string: String) -> Result<()> { - Ok(()) - } - fn copy_selection(&self) -> Result<()> { if let Some(diff) = &self.diff { let lines_to_copy: Vec<&str> = diff @@ -289,7 +267,9 @@ impl DiffComponent { try_or_popup!( self, "copy to clipboard error:", - Self::copy_string(lines_to_copy.join("\n")) + crate::clipboard::copy_string( + lines_to_copy.join("\n") + ) ); } diff --git a/src/main.rs b/src/main.rs index 116a9f4bb8..9a5894a8c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ #![warn(clippy::missing_const_for_fn)] mod app; +mod clipboard; mod cmdbar; mod components; mod input; From eec78e7c4054b569b9e67d95d33dbf37e2ff62eb Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 1 Sep 2020 01:26:31 +0200 Subject: [PATCH 5/6] dont show copy cmd when not supported --- src/clipboard.rs | 10 ++++++++++ src/components/diff.rs | 16 ++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/clipboard.rs b/src/clipboard.rs index a3f4808db5..b0c3e42ff4 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -18,3 +18,13 @@ pub fn copy_string(string: String) -> Result<()> { pub fn copy_string(_string: String) -> Result<()> { Ok(()) } + +#[cfg(feature = "clipboard")] +pub fn is_supported() -> bool { + true +} + +#[cfg(not(feature = "clipboard"))] +pub fn is_supported() -> bool { + false +} diff --git a/src/components/diff.rs b/src/components/diff.rs index 5038edf6ec..ead6ed8bac 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -604,11 +604,13 @@ impl Component for DiffComponent { self.focused, )); - out.push(CommandInfo::new( - strings::commands::copy(&self.key_config), - true, - self.focused, - )); + if crate::clipboard::is_supported() { + out.push(CommandInfo::new( + strings::commands::copy(&self.key_config), + true, + self.focused, + )); + } out.push( CommandInfo::new( @@ -688,7 +690,9 @@ impl Component for DiffComponent { } } Ok(true) - } else if e == self.key_config.copy { + } else if e == self.key_config.copy + && crate::clipboard::is_supported() + { self.copy_selection()?; Ok(true) } else { From 66ceb0c5141956ef0fb1a600bde431a1c9f66e44 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 1 Sep 2020 01:33:33 +0200 Subject: [PATCH 6/6] version bumps --- CHANGELOG.md | 5 +++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88938310b9..c875f5c625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.10.1] - 2020-09-01 + +### Fixed +- static linux binaries broke due to new clipboard feature which is disabled on linux for now ([#259](https://github.com/extrawurst/gitui/issues/259)) + ## [0.10.0] - 2020-08-29 ### Added diff --git a/Cargo.lock b/Cargo.lock index 156e743a75..ef27c69104 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -419,7 +419,7 @@ dependencies = [ [[package]] name = "gitui" -version = "0.10.0" +version = "0.10.1" dependencies = [ "anyhow", "asyncgit", diff --git a/Cargo.toml b/Cargo.toml index c99add70d1..fc1f616195 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitui" -version = "0.10.0" +version = "0.10.1" authors = ["Stephan Dilly "] description = "blazing fast terminal-ui for git" edition = "2018"