summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Dilly <dilly.stephan@gmail.com>2020-09-01 01:36:38 +0200
committerGitHub <noreply@github.com>2020-09-01 01:36:38 +0200
commite5c38e8d4a23d879ef1d0fb4460f2d20a7004f38 (patch)
tree52b128a28af3a7ae32c2c4f0beb1e674ee023063
parent9be119a2f04da924d6c75e3bb3be6a910a80b93a (diff)
revert clipboard feature on linux to fix static linux binary build (#261)v0.10.1
-rw-r--r--.github/workflows/ci.yml7
-rw-r--r--CHANGELOG.md5
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml6
-rw-r--r--Makefile9
-rw-r--r--src/clipboard.rs30
-rw-r--r--src/components/diff.rs36
-rw-r--r--src/main.rs1
8 files changed, 66 insertions, 30 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5fcf1e67..99a7ccdb 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -70,10 +70,13 @@ jobs:
run: |
sudo apt-get -qq install musl-tools
- name: Build Debug
- run: cargo build --target=x86_64-unknown-linux-musl
+ run: |
+ 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
+ make build-linux-musl-release
+ ./target/x86_64-unknown-linux-musl/release/gitui --version
rustfmt:
name: Rustfmt
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88938310..c875f5c6 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 156e743a..ef27c691 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 5878bc49..fc1f6161 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 <dilly.stephan@gmail.com>"]
description = "blazing fast terminal-ui for git"
edition = "2018"
@@ -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 d12a548d..fa537a24 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/clipboard.rs b/src/clipboard.rs
new file mode 100644
index 00000000..b0c3e42f
--- /dev/null
+++ b/src/clipboard.rs
@@ -0,0 +1,30 @@
+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(())
+}
+
+#[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 1b8793a7..ead6ed8b 100644
--- a/src/components/diff.rs
+++ b/src/components/diff.rs
@@ -8,9 +8,9 @@ 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;
-use clipboard::{ClipboardContext, ClipboardProvider};
use crossterm::event::Event;
use std::{borrow::Cow, cell::Cell, cmp, path::Path};
use tui::{
@@ -21,8 +21,6 @@ use tui::{
Frame,
};
-use anyhow::{anyhow, Result};
-
#[derive(Default)]
struct Current {
path: String,
@@ -244,18 +242,6 @@ impl DiffComponent {
Ok(())
}
- fn copy_string(string: String) -> Result<()> {
- 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(())
- }
-
fn copy_selection(&self) -> Result<()> {
if let Some(diff) = &self.diff {
let lines_to_copy: Vec<&str> = diff
@@ -281,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")
+ )
);
}
@@ -616,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(
@@ -700,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 {
diff --git a/src/main.rs b/src/main.rs
index 116a9f4b..9a5894a8 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;